-
Moving back a certain number of Frames
Hey,
I'm trying to go back a certain number of frames (let's say 20) after I hit the "Left" keyboard key.
PHP Code:
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
function keyEvent ( e:KeyboardEvent )
{
switch ( e.keyCode ) {
case Keyboard.LEFT :
prevFrame();
case Keyboard.RIGHT :
nextFrame();
}
}
stage.addEventListener ( KeyboardEvent.KEY_DOWN, keyEvent );
That is what i have right now, but rather than simply having it go back one frame using (prevFrame(), i want it to jump back 20 frames. So if I was at frame 40, and hit the "left" button, then i'd go back to frame 20.
Any ideas? I'm a completely noob by the way I'm just beginning with AS3.
Thanks so much!
Cheers !
BOB
-
hey,
it is quite easy:
Actionscript Code:
gotoAndPlay ( currentFrame + 20 );
p.s. just add some checkings:
Actionscript Code:
value > 0 and value < totalFrames
--
there is a place for those who dare to dream...
Flash Developer
VISTAPARK GMBH
BÄRENSTRASSE 11-13
D-42117 WUPPERTAL
-
It worked perfectly, thank you so much
Cheers !
BOB
-
Follow-up
Hey,
I just had a quick follow-up. Let's say I only want the timeline to jump back 9 frames when I hit "Left" all the time EXCEPT when i'm at a frame-label called "entry-slide" and another frame-label called "rivalry-slide", whereby the timeline would only go backwards 1 frame.
This is what I have:
PHP Code:
function keyEvent ( e:KeyboardEvent )
{
switch ( e.keyCode ) {
case Keyboard.LEFT :
if (currentLabel != "entry_slide" or "rivalry_slide") {
gotoAndPlay ( currentFrame - 1);
}
else{
gotoAndPlay ( currentFrame - 9 );
}
case Keyboard.RIGHT :
nextFrame();
}
}
stage.addEventListener ( KeyboardEvent.KEY_DOWN, keyEvent );
But this is not working.... any ideas?
Thanks!
Cheers !
BOB
-
I realized the or doesn't work, so this is what i've setup, instead. In the particular instances where it needs to go back one frame, i just call the actual frame label, I still can't get it to work properly though .
PHP Code:
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
function keyEvent ( e:KeyboardEvent )
{
switch ( e.keyCode ) {
case Keyboard.LEFT :
if (currentLabel != "entry_slide") {
gotoAndPlay ("forces_slide");
}
if (currentLabel != "rivalry_slide") {
gotoAndPlay ("entry_slide");
}
else {
gotoAndPlay ( currentFrame - 9 );
}
case Keyboard.RIGHT :
nextFrame();
}
}
stage.addEventListener ( KeyboardEvent.KEY_DOWN, keyEvent );
Cheers !
BOB
-
Code:
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
function keyEvent( e:KeyboardEvent ) {
switch ( e.keyCode ) {
case Keyboard.LEFT :
if (currentFrameLabel=="entry_slide") {
gotoAndPlay( currentFrame - 1 );
} else if (currentFrameLabel=="rivalry_slide") {
gotoAndPlay( currentFrame - 1 );
} else {
gotoAndPlay( currentFrame - 9 );
}
break;
case Keyboard.RIGHT :
nextFrame();
break;
default :
break;
}
}
stop();
stage.addEventListener( KeyboardEvent.KEY_DOWN, keyEvent );
-
Thank you for all your help!
Cheers !
BOB
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
|