Link to home
Start Free TrialLog in
Avatar of sousflai
sousflai

asked on

how to assign goto next frame action with a space bar press

Within a movie clip I've made some stop markers. At these points I'd like the space bar to make the timeline move to the next frame and initiate a new animation. It sounds easy but for some reason nothing seems to work, thanks in advance
steve
Avatar of Montoya
Montoya

keyListener.onKeyDown = function() {
    if (Key.isDown(Key.SPACE)) {
       

                                 trace('space was pressed'); //or whatever code you want
            myMovie.gotoAndPlay(nextFrame);   //or whatever code you want



    }
};
Key.addListener(keyListener);



Avatar of sousflai

ASKER

I want to control timelines within movie clips, should I use this code on the main timeline or in the frame that I want it to be active. I should explain more. I have stop actions through various movie clips which I want the keppress of space to advance to the next frame. The problem is that at the final stop in a movie clip I want space to tell the main timeline to advance to the next frame where a new movie clip is waiting. Would your code assign the space bar a global function? or would it only affect the frame in which it is written in which case I can manualy change the result of the press?

many thanks Steve
I've tried using the code inside the movie clips timeline so that it knows not to disrupt the main timeline but unfortunatly it doesnt work

any ideas?
this code works


.on (keyPress "<SPACE>") {nextFrame();

}

but only on the main stage and not in movie clips otherwise it would solve my problem
ASKER CERTIFIED SOLUTION
Avatar of SamuelRostol
SamuelRostol
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial