Answer the question
In order to leave comments, you need to log in
How to add a number to the name of an object in Actionscript 3.0?
Hello.
for(var i=1;i<10;i++){
this.txt[i].text=Math.round(Math.random()*10);
}
Answer the question
In order to leave comments, you need to log in
Create the name dynamically, something like this:this["txt"+i].text=Math.round(Math.random()*10);
Of course, I'm not strong in actionscript, but maybe it's worth not replacing the text, but appending it?...
Math.round returns Number
Since as3 is typed, you should always cast the data to the correct types.
from number to line
var a:Number = Math.round(Math.random()*10);
a.toString() или String(a);
Number('123');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question