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
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MontoyaProcess Improvement MgrCommented:
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


sousflaiAuthor Commented:
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
sousflaiAuthor Commented:
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?
sousflaiAuthor Commented:
this code works

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


but only on the main stage and not in movie clips otherwise it would solve my problem
if you are in a movieclip, just do it this way:

.on (keyPress "<SPACE>") {

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.