views:

22

answers:

1

I have a series of sections in the timeline and I'd like to use gotoandplay. How do I begin playback of another section of the timeline. Is there a way to detect the end of gotoandplay?

for example: 3 objects and 6 frames.

each object has a animate in frame and an opposity animate out frame.

At each frame the user can pick any of the three objects but if an object is already animated in then is must first play it's 2nd animate out frame.

I need to detect the end of an animate out sequence to begin the first frame of the selected object.

I hope that makes sense and any help much appreciated.

Thanks

A: 

You question goes in a few circles, but I think I get what you want.

You can use framelabels for this and either an enterframe to check what the current framelabel is for the current frame. Or you can add a framescript to the frames you want to know about.

EnterFrame:

Add labels to the frames you know to know about in the timeline. Maybe name the framelabels something like "roll_start", "roll_end" etc.

then use an enterframe to test if you are on a frame that you are interested in like so:

addEventListener(Event.ENTER_FRAME, enterFrameHandler);
private function enterFrameHandler(e:Event):void {
    if (currentLabel == 'roll_start') {
        // Rollover started
    } else if (currentLabel == 'roll_end') {
        // Rollover ended
    }
}

FrameScript:

Use the undocumented frameScript method to add a script that dispatches a custom bubbled Event on the frames of interest, then just listen for that event, rather than listening for enterframe and checking every frame:

private static const TIMELINE_AT_LABEL:String = 'timelineAtLabel';
function frameScript():void {
    dispatchEvent(new Event(TIMELINE_AT_LABEL, true, true));
}

var rollStartFrame:int = 10;
var rollEndFrame:int = 20;
addFrameScript(rollStartFrame, frameScript);
addFrameScript(rollEndFrame, frameScript);

addEventListener(TIMELINE_AT_LABEL, atLabelHandler);
private function atLabelHandler(e:Event):void {
    var frame:int = e.target.currentFrame;
    if (frame == rollStartFrame) {
        // Rollover started
    } else if (frame == rollEndFrame) {
        // Rollover ended
    }
}
TandemAdam