ActionScript 2.0 :: Accessing All But One In An Array?
Dec 31, 2006How can I set "_visible = true" for one item in an array, and "_visible = false" for all the others?
View 14 RepliesHow can I set "_visible = true" for one item in an array, and "_visible = false" for all the others?
View 14 RepliesI'm so proud of myself. I figured this out all by myself and thought I would share. (If you can't tell, I'm new to AS) I needed a way to grab an item in a specific location and have it return an array of items. Here is how I did it:
[CODE]....
So this should be easy, but my actionscripting is pretty rusty.i have a series of movie clip buttons that I am enabling through a for-loop. The problem is, when i try to access these mc's, it isn't recognizing that they even exist.[code]
View 2 RepliesI'm having problems making a loop of different movieClips. I've been able to find info about duplicating the same movieClip but I can't seem to get it to apply to this. This is what I am working with: I have 13 different movieClips of an animated character. They are titled montyDog_mc, montyBear_mc, montyCat_mc, etc. I also have a next and a previous button. What I need to happen is for the movieClip animations to cycle through, one at a time, each time the user clicks the next or previous button. I think I should be creating an array of some sort but I am very confused about how I list the movie clips in an array and apply it to the button.
This is what I have:
montyArray = new Array();
montyBear[0] = "montyBear_mc";
montyBee[1] = "montyBee_mc";
montyCow[2] = "montyCow_mc";
montyDog[3] = "montyDog_mc";
[Code] .....
Am I targeting the movieClips properly?
Is it me or the indexs in the array are not valid after using splice?
Code:
var arr:Array=new Array(3);
arr[0]=porsh;//car objects..not implemented here just for exemple
[code]....
i am amuthavalli. i am new to the action script. so i want to know how tho define and access the two dimensional array in flash
View 1 RepliesHere's my code:
Code:
function loadProjects(loaded){
if(loaded){
projects = this.firstChild.childNodes;
[Code]....
the traces within the function return correct results, however when trace values of the arrays within the function and created by the xml are attempted results are returned 'undefined'.
Why can I not access arrays made in this way from outside of the function?
How do I access an array inside an .swf that is loaded using loadMovie?
this.createEmptyMovieClip("controlpanel", 999);
loadMovie("lessons/regulatoryrequirements.swf", controlpanel);
forward_btn.onRelease = function() {
attachMovie(screen_array[0], "currentscreen", 0, {_x:500, _y:360});
};
screen_array is the array I'm trying to access in regulatoryrequirements.swf.
How would I access the first element of this array first entering the frame. I want to get buttons[0], or brandingbtn, to be activated.
Code:
var currentButtonId:Number = 0;
var buttons:Array = [brandingbtn, printbtn, packagingbtn, mltimda, typebtn, funbtn];
buttonCall();
function buttonRelease() {
for(var i:Number = 0; i < buttons.length; i++) {
[Code] .....
I'm setting up some Radio Buttons. The desired effect is when you click a button, it calls a function which loops through an array of the button states, switching them off.
The stumbling block is changing the state of the buttons from on to off. I'm sure it's an issue with the way I'm trying to get the instant name (eg radioBtn1) into the MovieClip Variable 'currentRadioName'.
The error I receive is: TypeError: Error #1034: Type Coercion failed: cannot convert "radioBtn1" to flash.display.MovieClip.
So I'm trying to stick some object into a MovieClip object, which obviously doesn't work.
[Code]....
i used a for loop to addChild of a class object(movieclip) to the stage and at the end line of for loop after addChild i push it into an array and i add eventlistener to it , such as
for (var i:Number = 0; i < 9; i++) {
.....
clip = new CLIP;
......
[Code]....
and if i want to get the array number which currently accessing how can i do that ? for example, i drag one of the mc class from the array which has already added eventlistener above.
how can i get the number of the array which im accessing ? evt.target..... etc ?
how can I access my different array variables in a for loop?what i need to do is for every increment in my for loop i want to change my var array name so that i don't need to use if else condition.
Code:
var ship_array:Array = new Array("spaceship1", "spaceship2", "spaceship3", "spaceship4", "spaceship5", "spaceship6", "spaceship7", "spaceship8", "spaceship9", "spaceship10",
[code].....
loop run a function to add Objects to fall upon stage, how do i have my function access random objects within an Array to replaced Platform1
function addPlatform1(){
var p:Platform1 = new Platform1();
stage.addChild(p);
[Code]....
i recently posted a question on embeding XML,i have it working however im still struggling to access individual elements of an XML document i would like to work with, below is a basic XML structure id like to acess:
Code:
<Game>
<Level>
[code].....
This is probably something very simple, but I'm not too sure of the code used to access items within an array.Suppose I have an array like this (using Kirupa's Arrays example):
grocery = ["bananas", "oranges", "apples", "kiwis"];
trace(grocery);
And we've loaded up the corresponding variables/text for "bananas", thus the current item = bananas.Therefore the next item would be "oranges". How can I tell Flash that I want to access this next item?? (I'd like to be able to access it through a variable so that the same action can be applied when the item is "oranges" to move to the next item, which would now be "apples").
I have a "back button" scheme that includes using an array to store references to functions.However, when i have to troubleshoot something like this, one of the things i'd like to be able to trace is the names of the functions that are in the array. If i trace a for loop through the array i just get [type Function] for each function. I would like to look at it's name.Right now, im using a workaround that places objects with a func property and a funcName property, which is a string that needs to be indicated manually.
View 4 RepliesI cannot wrap my head around this simple concept. All I need to do is access the element in myArray at the third position on Mouse Over. I've tried myArray[i][2] but it come back as the last element in the array.Here is my code.
Code:
function xmlLoaded(event:Event):void {
myXML = XML(myLoader.data);
trace("Data loaded.");
[code]....
I have a class that creates an array from a config xml file. I set a private variable in that class and use a getter in other classes to access the array. The routine that uses the array does the following:
- Call the getter and assign the returned value to a local (private) variable tmpArray. the getter is a simple return() using a value that is established in the constructor.
- Uses a for loop to itterate over the contents
- Uses array.shift() to pop the item in tmpArray
The next time I run the routine, the contents of the array is empty. I'm using the same getter. I implemented the getter when I tried to manage both arrays in the same class figuring that as long as the original array was private (i also tried static), that the value would not change. I have since worked around the problem by moving the routine that fills up the original value from the constructor to the getter. So, consider the following code:
import flash.events.Event;
btn.addEventListener("click", btnHandler);
var myArray = new Array();
var myTmpArray = new Array()
myArray = ["one", "two", "three"];
myTmpArray = myArray;
function btnHandler(evt:Event) {
[Code] .....
If I create a variable myVar and set it to 1 then set myOtherVar = myVar, the both equal the same value. If I change the value of myOtherVar, myVar is not affected. But using the shift() method changes both the original and the copied array.
I have a dynamic class, which has an array declared normally, before runtime.Usually, you can dynamically access a variable, whether it has been declared or not with
myClass["variable"] = 4;
however, trying to do this with an array, like so
myClass["array[0]"] = 4;
does not store 4 into the first element of array, and instead stores it into the variable "array[0]". For instance, after executing the previous code,
trace(myClass.array[0]);
traces undefined, where as
trace(myClass["array[0]"]);
traces 4.
Is there anyway I can access the elements of the array dynamically?
private var myObject:Object = new Object();
private var myArray:Array = new Array();
myObject[dynamic_name] = true;
[code]......
I have an object with an Array of objects inside. Each object has a name property. To scope it directly I would use:
ActionScript Code:
obj._arrayOfObjects[0]._object name; // trace returns the first object's name in the array
if you understand this so far then here is an easy question for you.
[code].....
I need to create an Array of movieclips so that I'm able to read / modify / add its properties. I thought the best solution was to create an Array of strings with each movieclip's name and then using this to convert the string to an expression, but I don't really know what to do when I want to access one of its properties. Here's my code:
ActionScript Code:
var room:Object = new Object
room.objects = ["mcObj1", "mcObj2", "mcObj3"]
mcObj1.Description = "It's a ball and it bounces"
[Code]....
i have a problem accessing the objects present inside an array.
For example,
var array:Array=new Array();
var obj:Object = {};
var int a=1; var int b=1;var int c=1; var int d=1;
[Code]....
Later I am able to get the array length but how can i get the values inside the objects??
One more thing is i am sending this array to php so how can i access the object values inside an array in php.
I'm pretty new to AS3, but I have not managed to solve the following problem: basically adding instances of a bitmap on the stage (working), but then adding an event listener and knowing which is which. So for the first part:
[Code]....
i am making a few object of action script..,what special about this object is that in the contructor function of this object is that i make it to send a sprite parameter which will act as it's parent..,var anObject:myObject = new myObject(parentSprite);and in my main project i used those object and store it in an array after adding it to the stage.i do store it to an array cause i need to be able to refer back to it..everything was fine up until i need to call function inside that object which i already stored in an array. how should i call the function in that object from an array that stored the object?
View 4 RepliesI have a flex application that dynamically loads swfs and I want to to use a set of color pickers in an external component within the application to determine a color array in the loaded swf.
I figured that I can use a new array of the colorPickers, i.e.
public var colors:Array = new Array [ cp01.selectedColor, cp02.selectedColor, cp03.selectedColor, cp04.selectedColor, cp05.selectedColor]
Is it possible for the swf to read the Array if it's set up like that? If so what would I put into the swf to get it? If not what do I need to do?
I have a site I am working on for an athletic garment manufacturer. They would like to have a sample creator (product configurator) on the site so customers can get an idea what their ordered garments are going to look like. I have it all working except for one needed feature.The customer has requested that the creator have an input box where the customer can type their team name and have it appear on the drawn garment. They also need to be able to decide whether they want the name to appear in one of several various shapes. Similar to the Nike team builder am having a great deal of difficulty figuring out how to shape text in actionscript. With all of the shape tweening flash can do from the interface you would think a function would be available in actionscript
View 2 RepliesI have an xml say in following format
[Code].....
What I should do is parse an xml and from its node name create object property and then create an object array based on those property. Am I able to make myself clear.
I think it would be simplest to explain it like this:
[Code]...
I have used a method to shuffle a part of a Array, but i noticed that it does not work very well.When i run this method I sometimes get empty array values.So if you would try the example below and test it out some times you would get a right result but sometimes a wrong result.For example when i run this i get in my trace output:
a,b,c,d,g,,e,f (here after the g it goes wrong)
a,b,c,f,g,d,e (here it goes right)
a,b,c,d,,g,f,e (here it goes wrong)[code]...