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=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]
whichclip = this._name;
[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();