# String Variable Issue - please help

**URL:** <https://forum.kirupa.com/t/string-variable-issue-please-help/204982>\
**Category:** flash\
**Created:** [October 25, 2006, 3:54am UTC](https://forum.kirupa.com/t/string-variable-issue-please-help/204982 "2006-10-25T03:54:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfx1026](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jfx1026/32/2943_2.png) [@jfx1026](https://forum.kirupa.com/u/jfx1026)\
**Post date:** [October 25, 2006, 3:54am UTC](https://forum.kirupa.com/t/string-variable-issue-please-help/204982/1 "2006-10-25T03:54:56Z")

</div>

Flash 8, I have some XML creating a few simple arrays. These pull some movie clips onto the stage with incremented names: product1, product2 and so on.

Inside these clips I have some code that is supposed to pull data from the arrays and put that data into text fields.

The code goes like this:

whichclip = this;  
trace ("whichclip is this? = " + whichclip); - output: whichclip is this? = \_level0.product1

var temp:String = whichclip;

var temp:String = temp.toString();

trace (temp.length);  
char\_pos = ((temp.length)-1);

lastpos = temp.substr(-1,1);  
trace (lastpos); - output: ] - :to: why a bracket?

– end code

Shouldn’t this last output be the number 1? I want to use this number to call the correct node for each clip, and therefore the correct data associated. Any ideas? thanks, John

---

<div class="post-metadata">

**Author:** ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)\
**Post date:** [October 25, 2006, 6:01am UTC](https://forum.kirupa.com/t/string-variable-issue-please-help/204982/2 "2006-10-25T06:01:08Z")

</div>

[QUOTE=jfx1026;1984922]Flash 8, I have some XML creating a few simple arrays. These pull some movie clips onto the stage with incremented names: product1, product2 and so on.

Inside these clips I have some code that is supposed to pull data from the arrays and put that data into text fields.

The code goes like this:

whichclip = this;  
trace ("whichclip is this? = " + whichclip); - output: whichclip is this? = \_level0.product1

var temp:String = whichclip;

var temp:String = temp.toString();

trace (temp.length);  
char\_pos = ((temp.length)-1);

lastpos = temp.substr(-1,1);  
trace (lastpos); - output: ] - :to: why a bracket?

– end code

Shouldn’t this last output be the number 1? I want to use this number to call the correct node for each clip, and therefore the correct data associated. Any ideas? thanks, John[/QUOTE]

```auto
whichclip = this._name;

```

---

<div class="post-metadata">

**Author:** ![jfx1026](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jfx1026/32/2943_2.png) [@jfx1026](https://forum.kirupa.com/u/jfx1026)\
**Post date:** [October 25, 2006, 2:46pm UTC](https://forum.kirupa.com/t/string-variable-issue-please-help/204982/3 "2006-10-25T14:46:10Z")

</div>

[quote=stringy;1984973] ActionScript Code:  
[FONT=Courier New][LEFT]whichclip = [COLOR=#0000FF]this[/COLOR].[COLOR=#0000FF]\_name[/COLOR];  
[/LEFT]  
[/FONT]

[/quote]

This helped. Once I was able to lose the \_level0 nonsense, the substr worked like a charm.

Final code looked like this:

whichclip = (this.\_name);  
trace ("whichclip is this? = " + whichclip);

lastpos = whichclip.substr(-1,1);  
trace (lastpos);

t = \_parent.titles[lastpos-1];  
s = \_parent.subhead[lastpos-1];  
c = \_parent.contents[lastpos-1];  
p = \_parent.image[lastpos-1];

imagemc.loadMovie§;  
stop();
