PDA

View Full Version : on <keypress> without buttons


ChaoZ
02-05-2006, 03:20 PM
Hi, I'm working on a presentation that I wish to advance using a keyboard button. Now I'm using the presentation format Macromedia provided, which uses slides and that's ok, but I want more timeline control within the slides.

I'm a newbie to scripting, so I tried stop(); on frame 15, then put in:

on (keyPress "<Space>") { gotoAndPlay(16);
}

Except it returns the error that I need to use that with a button instance. I suppose I could use an invisible button, but is there another way to control the timeline movement within a slide without having visible controls? It's going to be on a projector, so seeing buttons or mouse cursors would look ugly.

luke_the_duke
02-05-2006, 04:27 PM
Hi,

that should help. But don't try to work with this within the onKeyDown-Function, because it refers to the Listener Object and not to the current TimeLine.



var myListener:Object = new Object();

myListener.onKeyDown = function () {
if (Key.isDown(SPACE)) {
//your actions here
}
}
Key.addListener(myListener);

ChaoZ
02-05-2006, 09:37 PM
Wow, that's a lot more complicated than I thought it would be. Where exactly would I insert this code? I tried putting it right at frame 15 after a stop(); command but it didn't resume after hitting space.

Where you put the comment, I put in gotoAndPlay(16);

ASG
02-06-2006, 12:35 AM
or instead of that you could make a small button and then just put it so that it is outside of the visible range on the stage (in the grey area) and have this script on it.


on (keypress "<Enter>") {
gotoAndPlay(16);
}

or whatever keypress and frame you want

ChaoZ
02-07-2006, 09:14 PM
The idea suggested by the previous poster worked... for a while.

For some reason, after adding in some video clips in a different slide, it stopped functioning. I don't even know if it's the videos that caused it (I've tried switching keys to see if there's a conflict of some kind, didn't help). Here is the code I used on the button which is off to the side.

on (keyPress "m") {
gotoAndPlay(this._currentframe+1);
}


Simple enough. The sequence of events is ideally as follows:

1. Movie plays
2. Movie hits stop point and stops
3. I hit a key on the keyboard
4. Flash moves one frame after the stop frame and continues playing until the next stop point.

I've placed stop(); commands on a separate layer on the timeline.

Can anybody help?