Welcome to WebmasterWorld Guest from 54.227.82.149

Forum Moderators: open

Message Too Old, No Replies

Use variable value to access movie clip/button

     

mrscruff

10:25 am on Sep 16, 2008 (gmt 0)

5+ Year Member



Hello,

I run through an array and for each one add a movie clip which in turn has a button in it, and I need to add the onRelease action to the button.

this is what i have tryed, but to no resolve:

[2]
for (var x = 0; x < totalEvents; x++) {
var eventNode:XMLNode = rootNode.childNodes[x];
xmlCount++;

ImageHolder.attachMovie('eventImage', 'event'+(x+1), (x+3), {_x:pad, _y:0, _width:100});

var [b]button[/b]:String = 'event'+(x+1);
ImageHolder.[b]button[/b].eventButton.onRelease = function () {
trace ("onRelease called");
};
pad += 110;
}
[/2]

If I add the follow after the loop it works

[2]
ImageHolder.[b]event1[/b].eventButton.onRelease = function () {
trace ("onRelease called");
};
[/2]

But the number of items can changes, and would be better to do in the for loop.

How could i do this, thanks.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month