0

I have two buttons that are in a movieclip, how can I reference them like I have done with the 2 buttons below so that they can be added into an array?

container.anotherButton and container.anotherButton2 are the buttons I want to add to the array.

var agreeButton:SimpleButton;
var disagreeButton:SimpleButton;

var buttonArray:Array = new Array(agreeButton, disagreeButton);

for (var i:int = 0; i < buttonArray.length; i++) {    
   buttonArray[i].addEventListener(MouseEvent.CLICK, mouseClick);
}

1 Answer 1

2

I am not sure what the question is, I think this is what you need.

var buttonArray:Array = new Array(container.anotherButton, container.anotherButton2);

The reference will hold even if you move the container/buttons.

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

2 Comments

Thank you. I don't know why I over complicated that.
The reference will hold, no matter how you re-add the components to display list, since every object's reference is unique and tied to the particular location of that object in machine's memory. The path to that object in Flash's display list has no effect to the reference's value.

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.