Strings and variables

I have a single textbox with an instance of “box1”.

box1.text = “Hi there”;

The above works, but can you tell me why the below examples DO NOT work? I need these to work because I have an array that is spitting out numbers and I need to be able to somehow merge these a variable.

<snip>
count = 1;
adnumber = “box” + count;

adnumber.text = “1try”;

(box + count).text = “2try”;
</snip>

Sorry if my terminology isn’t the best…I’m still new. :slight_smile:

Cheers,
Hubert

assuming ‘box1’ is on the root,

_root[“box”+count].text = “2try”;

would be the correct syntax for the last line of your code

… and if its not (on the root timeline), use

this[“box”+count].text = “2try”;

:slight_smile:

Sorry to bump such an old thread, but why is it

this[“box” + ii].text= …

instead of

this.[“box” + ii].text=… (notice the period after “this”)

I know AS doesnt like it when you have brackets after a period, but it took me about 3 hours to figure this out, it seems to go against the regular structure… and how was i supposed to know that [ replaced a period?
sigh

[] signifies an array. All objects in the timeline are stored in array and this[“box” + ii] searches the objects in the current timeline you are on for whatever value “box”+ii equals (box1, box2, whatever).