Skip to main content

Actionscript 3: targeting issue 44 Responses

Last post: 3 years, 10 months ago | Thread started: Jul 26, 09, 5 p.m.

RespondNew TopicDisable Images

  • 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.

    Jul 26, 09, 5 p.m. – Permalink
  • dijitaq

    use the getChild method. maybe something like this
    var button:MovieClip = targetMC_mc.getChildByName("btn...
    button.yourAction();

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earJul 26, 09, 5:17 p.m. – Permalink
  • CyBrain

    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...
    }

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earJul 26, 09, 6:11 p.m. – Permalink
  • PonyBoy

    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

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earJul 26, 09, 6:23 p.m. – Permalink
  • PonyBoy

    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

    next note >add note

    You must be logged in to add a note. Login now or register for an account.

    Cancel
    Dog-earJul 26, 09, 6:24 p.m. – Permalink

Login or Register to respond to this

Skip to main content