/ Published in: ActionScript 3
URL: http://theflashconnection.com/content/creating-and-dispatching-your-own-custom-events-as3
A very easy way to have child movieclips cause events in their parent code to occur.
Expand |
Embed | Plain Text
stage.addEventListener(MouseEvent.CLICK, stageClicked); function stageClicked(event:MouseEvent):void { stage.removeEventListener(MouseEvent.CLICK, stageClicked); clip1.play(); } clip1.addEventListener("done", clip1Done); function clip1Done(event:Event):void { clip2.play(); } clip2.addEventListener("done", clip2Done); function clip2Done(event:Event):void { clip1.gotoAndStop(1); clip2.gotoAndStop(1); stage.addEventListener(MouseEvent.CLICK, stageClicked); } // at the end of the timeline of a child movieclip (such as in this example of "clip1" or "clip2" you add this: stop(); dispatchEvent(new Event("done"));
You need to login to post a comment.
