Actionscript 3: targeting issue
- Started
- Last post
- 4 Responses
- CyBrain
What would be the best approach to target a button in a movie clip?
Obviously, the simple direct approach in AS2 (targetMC_mc.btn) is completely unusable.
- dijitaq0
use the getChild method. maybe something like this
var button:MovieClip = targetMC_mc.getChildByName("btn...
button.yourAction();
- CyBrain0
What I did was use a linkage name (Welcome) for my movie clip intro and after that the references I made to the new name (intro) let me target my button (enterBtn_mc) inside
var intro:Welcome = new Welcome();
addChild(intro);
intro.enterBtn_mc.addEventListen... enterOverListener);
function enterOverListener(e:MouseEvent... {
intro.enterBtn_mc.gotoAndPlay("o...
}
- PonyBoy0
place the movieClip dynamically...
make sure it's available at runtime as a class - when you place it dynamically - you give the new instance of that class a specific name...
var myMC : customMC = new customMC ( ) ;
myMC.buttonMc... whatever
- PonyBoy0
haha...
... I had this thread sitting opening and didn't bother to refresh...
... you did exactly what I would have done (as you can see). :D