0

I have an array, and I would like to make a function onRelease for all of the array positions.

The code would be like:

pick = new Array(2,3,4);
var botoes1:MovieClip = lev.attachMovie("block", "block_"+lev.getNextHighestDepth(), lev.getNextHighestDepth(), {_x:550, _y:1*22});
_root.botoes1.gotoAndStop(pick[1]);
var botoes2:MovieClip = lev.attachMovie("block", "block_"+lev.getNextHighestDepth(), lev.getNextHighestDepth(), {_x:550, _y:2*22});
_root.botoes2.gotoAndStop(pick[2]);
var botoes3:MovieClip = lev.attachMovie("block", "block_"+lev.getNextHighestDepth(), lev.getNextHighestDepth(), {_x:550, _y:3*22});
_root.botoes3.gotoAndStop(pick[3]);

for(i=0;i<3;i++){
    _root['botoes'+i].onRelease() = Function () {

    }
}

but it doesn't work this way... and if possible, how can I make the MovieClip declaring for all the buttons in an for loop?

1 Answer 1

1

Couple syntax errors there, here's what this line should look like:

_root['botoes' + i].onRelease = function()
{
    // Function body.
    //
}

Your previous code was trying to assign the result of _root['botoes' + i].onRelease() (which would have been undefined) to the result of Function() (which would have been a Function object).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.