|
-
Play a MovieClip from in another Movieclip...
Hi guys,
I have 2 movieclips on stage - "clipA" and "clipB"
Both are animations - at the end of "clipA" - i want to use the AS3 version of _root.clipB.play()
Then at the end of clipB - i want to use _root.thisFunction()
To run a function on the stage.
Thanks for any help!
-
You can do this.
MovieClip(root).clipB.play();
and
MovieClip(root).thisFunction();
-
Total Universe Mod
gasp, technically ok, but bad practice.
Better to put this on the main timeline:
Actionscript Code:
clipA.addEventListener(Event.COMPLETE, onClipAComplete); clipB.addEventListener(Event.COMPLETE, onClipBComplete);
function onClipAComplete(event:Event):void{ clipB.play(); }
function onClipBComplete(event:Event):void{ thisFunction(); }
function thisFunction():void{ // do stuff }
Then on the last frames of both clipA and clipB, put this:
Actionscript Code:
dispatchEvent(new Event(Event.COMPLETE));
-
@jAQUAN : Please don't mind. I just modified your code a little to make a continuous dispatchEvent.
Actionscript Code:
clipA.addEventListener(MouseEvent.CLICK,clickListener); clipB.addEventListener(MouseEvent.CLICK,clickListener);
function clickListener(evt:MouseEvent):void { evt.target.addEventListener(Event.ENTER_FRAME,efListener); clipA.addEventListener(Event.COMPLETE, onClipAComplete); clipB.addEventListener(Event.COMPLETE, onClipBComplete); evt.target.play(); } function efListener(evt:Event):void { if (evt.target.currentFrame==evt.target.totalFrames) { evt.target.dispatchEvent(new Event(Event.COMPLETE)); thisFunction(evt.target); } } function onClipAComplete(event:Event):void { clipB.play(); clipB.addEventListener(Event.ENTER_FRAME,efListener); } function onClipBComplete(event:Event):void { clipA.play(); clipA.addEventListener(Event.ENTER_FRAME,efListener); } function thisFunction(clip):void { trace(clip.name); }
@itsallgood : You can even do this by which you can write your code in only one place.
FFA
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|