ActionScript 3.0 :: Dynamic Variable Name Array?
Jan 4, 2010I'm new to AS3 and converting some old AS2 code that uses dynamic variable names. I know that you cannot do this in AS3>? [code]...
View 1 RepliesI'm new to AS3 and converting some old AS2 code that uses dynamic variable names. I know that you cannot do this in AS3>? [code]...
View 1 RepliesI think it would be simplest to explain it like this:
[Code]...
I'm going to post the full code of the two functions, disregard the "fluff" unrelated to the two functions as it is all working flawless, I've tested this HEAVILY and cannot understand why it keeps setting the entire array to undefined!
Code:
// processReplace Function
function processReplace(transferFiles) {
var processArray:Array = transferFiles.slice();
[Code]....
Basically it's supposed to check to see if the file exists and return as true if it does and add it to a replace array, then the replace array is processed into a single string and put into a dialog box through the flash wrapper prompting them to "replace the files or not".
It makes the replace array just fine, it actually even has the right "count" in it but it's setting all the "filenames" to undefined because of the exists = processSearch function.
I even tried to make a new array and run the search just from that one and set the values from the old one and it's still failing.
Is it because of the "break" or can anyone figure it out? Iknow it's hard because you can't use the code
I want to change the value of a variable listed in an array using the array. for example:
Code:
var theVariable:Number = 15;
var theArray:Array = [theVariable];
now if I try this
Code:
theArray[0] = 20;
I just get an array with 1 value of 20 in it and it no longer references theVariable what i want to do is change the value of theVariable with out removing it from the array but referencing it from the array in a loop or something.
can't figure out why the dynamic text boxes in my dynamic clip arent picking up the variable when I loop through this recordset!the trace (you'll see here right after I try two ways to assign the variable) traces the correct info back..
[code]...
Is it possible to, if you have an array of class names like ActionScript Code: var city01names:Array = ["pic_01", "pic_02", "pic_03" ...] make a new array which would read these names, instantiate them, and push them into a new array containing the instances of all these pictures, which I could then use for a slideshow?
[Code]...
I want to loop through an array and use the array value to reference a variable.
The Setup:
(For illustration only. Not actual script)
My MCs:
triangle_mc
square_mc
[Code]....
I'm trying to make something that will show up in a dynac text field something like this:"[variable1] text text text [varibale2] text text text"I've linked the dynamic text field to a variable "resu" and set it to:var resu = variable1 + "text text text text" + variable2 + "text text text"The only problem is that when I make the variables random, they don't change
View 1 RepliesI have a movie clip and in that movie clip there is a dynamic text box. I want that text box to display a dynamic variable name something like:
Quote:
_root.var_[this._name]
so the variable will be _root._var plus what ever the instance name of the movie clip it's in is, how can i do this?
Sorry if the title is a little confusing. Here's what I meant - I have an array and and object. Let me give a visual:
This is my object:
obj["id"] = ["1","2","3"];
obj["name"] = ["na","no","ne"];
my itemArray:
itemArray = ["id","name"];
[Code]....
but it doesn't work. How do I actually use the arr[i] variable in the array? :s
Wanting to add an array to a MC like:
var mc:MovieClip = new MovieClip();
mc.myarray[0] = movieclip1; // some mc name
mc.myarray[1] = movieclip2; // or push it
[code]....
I basically need to load information from an XML. Then depending on which button is clicked(apartment in a building) that specific info from the xml needs to load in a txt field.
Here is my actionscript and xml code. I'm stuck on how to assign " i " to each apartment in the building.
[Code]...
I have an array variable called ball[#], which value starts at 0 and is incremented up to 8. I also have a corresponding array variable called _ballPlaced which returns true or false if a ball is placed in a target zone. What I would like to do is retrieve the array value variable from the ball[#] at any time. For instance, the ball[#] variable can be clicked and dragged, so when it's selected it becomes the event.target. E.g. How can I put the array value of the ball[0] in the ball _ballPlaced array.
ActionScript Code:event.target._ballPlaced[/* retrieve vale of ball[0] array i.e. 0 and put it in here */]
I am desperate about this.[code]...
Another thing: how to access array values from outside of function?
I want to loop through an array and use the array value to reference a variable. The Setup:(For illustration only. Not actual script)
[Code]...
I have a app that currently gets event data from facebook and displays this into a list[code]...
View 1 RepliesI have global variables:
_global.var1Array
_global.var2Array
_global.var3Array
_global.var4Array
and so forth.The issues is I need to call a variable from within the array but depending on an option the user has chosen it needs to call the right one.At the moment I am trying
end = "_global.var"+userOption+"Array["+array#+"]";
userOption being the needed array
array# being the needed entry within the array.
However when I try and use this I of course just get it like a string, not as a variable...
I have an array variable called ball[#], which value starts at 0 and is incremented up to 8.
I also have a corresponding array variable called _ballPlaced which returns true or false if a ball is placed in a target zone.
What I would like to do is retrieve the array value variable from the ball[#] at any time.
For instance, the ball[#] variable can be clicked and dragged, so when it's selected it becomes the event.target. E.g. How can I put the array value of the ball[0] in the ball _ballPlaced array.[code]...
What I have: 2 buttons on stage (NEW_YORK and CHICAGO) which are given an onRelease function trough a forLoop (so far so good).
What I need: For those to buttons to trace their own array item when i press them.
The problem: If I summon the array item static (array[1]) it works, but when i try to make it dynamic (array[i]) it comes back as undefined.
I enclosed the .fla.[code]...
I'd like to use a variable for the field name of the associative array, but my brain is not remembering what I did long time ago when I needed it.
[Code]...
Does anyone know if it is possible to have an Array containing predefined variables - then modify a variable using the array?
For example
ActionScript Code:
var data1:String = new String;
var data2:String = new String;
[Code]....
This will currently trace 111 - can I get it to trace "Hello"?
I have a series of buttons within an array called (a,b,c,d,e,f,g,h,i) see below
ActionScript Code:
var myArray:Array = [a, b, c, d, e, f, g, h, i];
for (i in myArray) {
[code]....
I have four checkbox and store the value in the Array. So if check all the boxes than I have an Array which have value = 1,1,1,1
I want to compare that with a variable which has same value 1,1,1,1
If the both value is same than it will display correct feedback.
var user_response:Array = ["0", "0", "0", "0"];
var correct_answer = "1,1,1,1"
Here is the code
if (user_response == correct_answer ){
trace("Correct");
}
else {
trace("Incorrect");
}
I keep getting "Incorrect" even if I had selected all checkboxes.
I have an array named "lagers1" when I trace lagers1[0] I get: lagers1[0]= _level0.firth_l0
Now I want to decide if "firth" is in the name of "_level0.firth_l0". I have tried with slice but all the time it shows undefined. Is there a way to get a part of an arraymname in a variable?
Is there a way to obtain the variable name that is inside an array?[code]...
View 2 RepliesI have three array holders that hold different text and numbers. First I need if(_root.achievements[0][i] (Needs to be evaluated as a string variable name for example _root.pKills because before I set _root.pKills to 10) == _root.achievements[1][i] (Need to be evaluated as a number so I can compare it to the string variable name))
[Code]....
im doing a loop to attribute the values to _x property, and use it to make random movimets with movieclips.i ve got 16 movieclips in my stage, named b1, b2, b3....b16 and the code is
Code:
count = 0
chama = setInterval(function () {
count++[code]....
so... after 3 time that setinterval execute this function, i�d like to call a function to get this movieclips, in their current positions and take them in especifics positions on stage.so I created an Array and I�m trying to use this code to define variables with values from the Array, and make a moviment to the especifics positions
Code:
xC = [63.9, 16.95, 45.85, 65.55, 18.75, 26.2, 55.85, 55.25, 28.85, 21.95, 36.6, 35.75, 14.7, 45.7, 14.45, 60.75]
function cPos () {
for (a=1; a<=16; a++) {[code]...but it�s not working...why??what can I do to Take the variables inside the array and use them to respectives movieclips b1, b2....b16?
Is it possible to get values for a variable from an array.How would i do this?
View 2 RepliesI have an array with about 80 variables in it and everything is working fine, but I can't seem to figure out how to produce a variable name from the array. Example: I sort my array to get the highest value, then I cannot retrieve the actual name of the variable that holds the value.
[Code]...
I looked into "toString" and toLocaleString but they also gives me the number value.
fairly simple question (with a long explaination). I have an array, created from the results of another array and it's position in that array. There are actually multiple arrays It can be created from.
Eg.
Array1: clientName1, clientName2, etc.
Array2: clientType1, clientType2, etc.
Second Array: [clientName1,0], [clientName2,1] OR [clientType1,0] etc.
[Code]...
My issue is, I would like to be able to dynamically adjust the array that it is generating from. This would mean changing the bold bit of the code above. I have tried declaring a variable (type = names+"[i]") and using it in the linkArray declaration, however it will not see this as an array reference, only as a variable. What I want to know is, how do I reference the name of the original array as a variable so I can update it dynamically?