Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Use variable value to access movie clip/button



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

5+ Year Member


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:

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

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;

If I add the follow after the loop it works

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

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