-
Why does this cause it to skip?
I have this actionscript that works fine until you try and move your mouse
once you move it, the frame skips back to the beginning
why??
Code:
onClipEvent (enterFrame) {
stop();
}
on (keyPress "<Space>") {
play();
}
-
onClipEvent (enterFrame) {
stop();
}
Remove that.
-
I can't, if I do then it will the movie will play...and I don't want that until you press the space bar via the 2nd part of the code
-
Yes you can, it should only be a stop(); in the FRAME not on the movieclip or button or whatever your using.
-
didn't work it just plays it, no stopping action
-
Total Universe Mod
change it to:
Code:
onClipEvent(load){
this.stop();
}
-
great but how come when I hit spacebar, play, it just jumps back to the beginning
-
and when I move my mouse it jumps back to the beginning
-
Try this instead:
Code:
if (Key.isDown(Key.SPACE)) {
play();
}
-
Total Universe Mod
There's no correlation between mouse movement and playback (unless of course you are specifically using a mouse listener to control playback for some reason)
onClipEvent() commands must be placed directly on a movie clip.
So we are assuming you have a movie clip on stage with the code you provided.
//load commands fire once and only once when the clip appears for the first time
onClipEvent('load'){
}
//enterFrame commands fire every frame according to your movies framerate
onClipEvent('enterFrame'){
}
By putting a stop() in there you are forcing the timeline to stop immediately and it wont start playing again until space is pressed.
Btw, on() and onClipEvent() are barely used anymore. All code is put on the timeline now.
Read here for more
http://www.kirupa.com/developer/mx/movement_keys.htm
-
-
ok so I have this actionscript on my movie clip on the first frame of the movie
Code:
onClipEvent(load){
this.stop();
}
on (keyPress "<Space>") {
play();
}
but when I try to copy and paste the frames, it doesn't stop it just keeps going. Even with the stop on the movie actionscript and the frame...how can I get this to work. My overall objective is to have a video that plays when you hit space and has to loop 12 times before continuing but, you have to hit space to start the loop
-
Total Universe Mod
Originally Posted by kraxyk
My overall objective is to have a video that plays when you hit space and has to loop 12 times before continuing but, you have to hit space to start the loop
Heh, that should have been your first post.
Start a new flash file. Then create a new layer and name it actions.
on frame 1 of actions place this code.
PHP Code:
stop();
var timesPlayed:Number = 0;
keyboardListener = new Object();
keyboardListener.onKeyDown = function(){
if(Key.SPACE == Key.getCode()){
play();
}
}
Key.addListener(keyboardListener);
Then, select the last frame of the video on the actions layer, hit F7 (add empty key frame) and add this.
PHP Code:
if(timesPlayed < 12){
gotoAndPlay(2);
timesPlayed++;
}else{
stop(); //or whatever command for after it's played 12 times
}
-
it didn't work
it just keeps repeating
Last edited by kraxyk; 05-04-2008 at 09:16 PM.
-
Total Universe Mod
Then there is something different about your .fla than the setup I described.
This is assuming you ditched all the other code and placed mine on the root timeline, NOT a movieclip.
-
I did what you said, but just to let you know I have the default layer, a layer I created then the layer you told me to create, and also my video is on frame 97-109, and there is no actionscript on the movie of on the first frame
Last edited by kraxyk; 05-06-2008 at 03:31 PM.
-
I would say post your files somewhere for us to look at. Your not doing something right because everything he has suggested should work without a problem.
-
Total Universe Mod
Ok last shot, if not you're gonna have to hit the books.
Delete any actions I've given you so far and just put this on frame 1
PHP Code:
stop(); var startFrame:Number = 97; var endFrame:Number = 109; var timesPlayed:Number = 0; keyboardListener = new Object(); keyboardListener.onKeyDown = function(){ if(Key.SPACE == Key.getCode()){ startLooping(); } } Key.addListener(keyboardListener);
function startLooping(){ gotoAndPlay(startFrame); onEnterFrame = function(){ if(_currentframe >= endFrame){ if(timesPlayed < 12){ gotoAndPlay(startFrame); timesPlayed++; }else{ gotoAndStop(endFrame); delete onEnterFrame; } } } }
-
frame one of the whole flash file or just the movie?
and on which layer. Actions, default, or the other extra one
-
Probably he means frame 1 of the whole flash file, on the actions layer (ALWAYS use an actions layer for your actions.)
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
|