Reputation: 45
I have MC1 that when clicked i would like it to wait so it starts playing when MC2 hits frame 50 or 100. both have their own separate timeline. Any Help?
Upvotes: 1
Views: 99
Reputation: 5087
addFrameScript will let you add and remove code to/from a movieclip frame.
function onMc1Click(e:MouseEvent):void
{
//targetFrame:int = 50 declared in class..
mc2instance.addFrameScript(targetFrame, mc2TargetFrameReached);
mc2instance.play();
}
function mc2TargetFrameReached():void
{
//call with null function value to remove
mc2instance.addFrameScript(targetFrame,null);
//do other stuff
}
Upvotes: 3
Reputation: 359
mc1.addEventListener(MouseEvent.CLICK, onMc1Click);
function onMc1Click(e:MouseEvent):void
{
mc2.addEventListener(Event.ENTER_FRAME, onFrameMc2);
mc2.play();
}
function onFrameMc2(e:Event):void
{
if(mc2.currentFrame == 50 || mc2.currentFrame == 100)
{
mc2.removeEventListener(Event.ENTER_FRAME, onFrameMc2);
mc1.play();
}
}
Upvotes: 1