# Strings and variables

**URL:** <https://forum.kirupa.com/t/strings-and-variables/14193>\
**Category:** Uncategorized\
**Created:** [February 23, 2003, 4:03am UTC](https://forum.kirupa.com/t/strings-and-variables/14193 "2003-02-23T04:03:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![apocyber](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@apocyber](https://forum.kirupa.com/u/apocyber)\
**Post date:** [February 23, 2003, 4:03am UTC](https://forum.kirupa.com/t/strings-and-variables/14193/1 "2003-02-23T04:03:29Z")

</div>

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. 🙂

Cheers,  
Hubert

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 23, 2003, 4:15am UTC](https://forum.kirupa.com/t/strings-and-variables/14193/2 "2003-02-23T04:15:06Z")

</div>

assuming ‘box1’ is on the root,

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

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 23, 2003, 4:24am UTC](https://forum.kirupa.com/t/strings-and-variables/14193/3 "2003-02-23T04:24:34Z")

</div>

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

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

🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 18, 2003, 10:07pm UTC](https://forum.kirupa.com/t/strings-and-variables/14193/4 "2003-06-18T22:07:18Z")

</div>

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_

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 19, 2003, 2:46am UTC](https://forum.kirupa.com/t/strings-and-variables/14193/5 "2003-06-19T02:46:48Z")

</div>

[] 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).
