简体   繁体   中英

Button functionality in a movieclip within another movieclip for another movieclip

Ok so i have this looping thumbnails bar that goes like this:

Scene1-imagebar-imagebarinside

The buttons symbols are in the "imagebarinside" movieclip and i am using this code:

ss1.addEventListener(MouseEvent.CLICK, play1);

function play1(event:MouseEvent):void
{
gotoAndStop("ssbox1");
}

... in this movieclip to play another labeled frame in another movieclip (Scene1-Bara). Problem is it won't work :-<. If anyone has a better ideea i'll really appreciate it.

Not sure what is where from your code example, but the problem sounds like you are capturing the button event inside the button script but then trying to have another movie clip go play a frame?

Assuming imagebar is the movie clip and class that contains frame "ssbox1" you could add a listener to it that listens for the click event coming out of the contained button.

So inside the imagebar class add your listener

imagebarinside.ss1.addEventListener(MouseEvent.CLICK, play1);

then still in image bar add your handler

function play1(event:MouseEvent):void
{
 if(event.target.name=="box1button"){
  gotoAndStop("ssbox1");
 }
}

There's other ways to solve your issue but the main thing is to very aware where your event is getting generated, where it goes, and where you want to exert your "goto" control.

to play another labeled frame in another movieclip

Only what you need is a correct reference.

function play1(event:MouseEvent):void {
    //Now reference child of the top-most display object with name 'bara'
    MovieClip(root).bara.gotoAndStop("ssbox1");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM