Search  

ARRAY?

HomeForumsGeneral DiscussionArray?
55813 KNO3
159 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

Hi guys. I wanted to know if its possible to give something a name and add a variable to it…for example i have a loop from 1 to 10 with the variable i holding the count; in it i’m creating a dynamic button called myButton, and at the end of the loop i’m adding 1 to the i. Is it possible that i call the button creating dynamically myButton[i] or something so that it’s name would be myButton(and the number of the loop), therefore creating a new button for every loop….this would create 10 buttons. What do you think?

Posted 3 months ago
54344 iceonflames
247 posts
Exclusive author Referred at least one person Sold between 1 000 and 5 000 dollars
for(i=0;i<some_x;i++){
    attachMovieClip("mymc","my" + i + "_mc",i);
    this["my" + i + "_mc"].somevar = i;
}

I guess this is what you are asking for…right?

Posted 3 months ago
55813 KNO3
159 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

i’m creating a button dynamically in a loop. I need to name it myButton and the number of the loop so if the loop just started from 1, the button is called myButton1. The code you posted does that iceonflames?

Posted 3 months ago
40501 NnielsS
73 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

for(i=1;i<10;i++){

attachMovieClip("myButton","myButton"+i, i);

}

...

this["myButton"+i].onPress = function() {

trace("Button #"+this.getDepth()+" clicked!");

}

?

http://pastie.org/255830

Posted 3 months ago
55813 KNO3
159 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

could this be applied to a dynamic text field?

Posted 3 months ago
40501 NnielsS
73 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

yes!

}http://pastie.org/255868

Posted 3 months ago
38635 flasher3015
399 posts
Exclusive author Author was featured Referred at least one person Sold between 5 000 and 10 000 dollars Bought between 50 and 99 items

for(var i:Number = 1;i<=10;i++){
this.createTextField(“myButton”+i, this.getNextHighestDepth(), 0,0,0,0);
this[“myButton”+i].text = “dummy text”;
this[“myButton”+i].autoSize = true;
this[“myButton”+i].text.onRelease = function(){
//do stuff here
}
}

Posted 3 months ago
55813 KNO3
159 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

the onRelease is not working flasher :S

Posted 3 months ago
38045 Ziyad
108 posts
Referred at least one person Sold between 100 and 1 000 dollars
for(var i:Number = 1;i<=10;i++){
this.createTextField(“myButton”+i, this.getNextHighestDepth(), 0,0,0,0);
this[“myButton”+i].text = “dummy text”;
this[“myButton”+i].autoSize = true;
this[“myButton”+i].text.onRelease = function(){
//do stuff here
}
}

Try using the eval function instead of this

for(var i:Number = 1;i<=10;i++){
this.createTextField(eval(“myButton”+i), this.getNextHighestDepth(), 0,0,0,0);
eval(“myButton”+i).text = “dummy text”;
eval(“myButton”+i).autoSize = true;
eval(“myButton”+i).text.onRelease = function(){
//do stuff here
}
}

Posted 3 months ago
55813 KNO3
159 posts
Referred at least one person Sold between 100 and 1 000 dollars Bought between 1 and 9 items

i have this command:

user_so.data.tname = name_txt.text;

and would like to add the variable “i” to the tname…any help?

Posted 3 months ago