View Full Version : How Do You Make An Array?
I_Dont_Have_A_Name
08-17-2003, 04:05 PM
am trying to make an array with numbers in it and then print one of them out into a text field
here is what i tried but it does not work... i would think it would print out 6
onLoad () {
number = new Array(5,6,4,2,5,1);
test.text = number(2);
}
Brian Ayers
08-17-2003, 05:11 PM
A couple of things to note here ...
First of all -- creating an array using most methods - will not work with SWF4 ...
So, make sure to open the Export panel - and set it to use SWF5 for the Flash type ... (it does work in the internal player as well) ..
Here is a sample code:
onLoad () {
* *number = new Array(1,2,3,4,5);
}
onFrame (50) {
* *disText = number[4]; // displays "5"
}
onFrame (54) {
* *stop();
}
I used a variable for the dynamic text field -- not the field.text method -- I prefer to set it as a target, open the advanced options and give it a variable name -- then target the variable, not the dot text method.
Also ... the number inside the brackets (not parentheses as you've used in your code) starts with Zero ...
So, based on the code I posted above ...
number[0] = 1
number[1] = 2
number[2] = 3
number[3] = 4
number[4] = 5
based on your example:
number[0] = 5
number[1] = 6
number[2] = 4
... etc.
Hope it helps,
Cheers,
Brian
I_Dont_Have_A_Name
08-17-2003, 05:22 PM
thanks Brian it works now
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.