-
Playback control of nested movieclips (as symbols)
Hey all,
I'm trying to figure out how to control a movieclip symbol from the main timeline.
I've created a Main Timeline with one symbol per frame, a labels layer and an action layer.
Each frame has its own label, and each action keyframe has a listener attached to the current symbol like so:
Code:
symb = title_mc;
symb.cacheAsBitmap = true;
symb.mask = f_mask;
symb.focusRect = false;
stage.focus = symb;
symb.addEventListener(KeyboardEvent.KEY_DOWN, mc_pager);
I need the following structure:
- From Main timeline Frame
- Identify symbol instance (labeled as <name>_mc)
- Inside symbol timeline, play from first frame (labeled '0') until next labeled frame ('1' and so on)
- stop and wait for next pg_down to start playing from next labeled frame to the following (i.e. '1'-'2'), or pg_up to start playing from the previous labeled frame (i.e. '0' - '1')
- on last frame (labeled 'final') exit symbol focus and return keyboard control to main timeline to allow pg_down and pg_up to move to the next / previous frame. on pg_up on symbol.currentFrame == 0, do same.
This is the code I'm currently stuck with:
Code:
import flash.events.Event;
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stop();
f_mask.cacheAsBitmap = true;
var symb:MovieClip;
symb = MovieClip(root); //assign symbol I want to be controlled by pg_up/pg_down
symb.focusRect = false;
symb.addEventListener(KeyboardEvent.KEY_DOWN, mc_pager); //add keyboard event listener
stage.focus = symb; //focus on current symbol
function mc_pager(e:KeyboardEvent):void{
var myKey = e.keyCode;
if (myKey == Keyboard.PAGE_DOWN){
do{
symb.play(); // it plays, then checks if the lbl is null or final, then quits
trace("current: " + symb.currentFrameLabel);
} while (symb.currentFrameLabel == null && symb.currentFrameLabel != 'final');
symb.stop();
symb.removeEventListener(KeyboardEvent.KEY_DOWN, mc_pager);
stage.focus=MovieClip(root); //return focus to main timeline (in the next keyframes, the focus is on the nested_mc
}
if (myKey == Keyboard.PAGE_UP){
do{
symb.prevFrame();
} while (symb.currentFrameLabel == null && symb.currentFrameLabel != '0');
symb.stop();
symb.removeEventListener(KeyboardEvent.KEY_DOWN, mc_pager);
stage.focus=MovieClip(root);
}
}
So far, I've tried several different things (including multiple eventhandlers) to no avail. This is what looks best so far, being logically sound (I think). But it doesn't work. Please, I need a hand with this.
Thanks a lot for any help!
Tags for this Thread
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
|