View Full Version : How to make a back function using a keyboard key?
solarboi
08-06-2009, 08:50 PM
the scenerio goes. I have 2 scenes. if i wan flash to play back the previous scene using a key eg. backspace, how do i go about doing it?
Another qns i would like to ask too.
for example. I have 3 scenes. A is the main scene, B is the 2nd and C is the third. The flash will play as follow. A, B, then back to A again then C. Is there any actionscript to do this?
Thx in advance to the scripters here :)
svenjoypro
08-07-2009, 12:59 AM
stage.addEventListener(KeyboardEvent.KEY_DOWN, downHandler);
function downHandler(event:KeyboardEvent):void {
if(event.keyCode == 8) { // IF backspace pressed
gotoAndPlay(1); // OR prevFrame();
}
}
I believe that should do it for the back button. This link will show you all of the key codes (you need to change the 8 to whatever number you need):
http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001136.html
For the second question:
Make a boolean variable (for example var bVisited:boolean = false; )
then on scene 'A', right before you go to scene 'B' put the following:
if (bVisited) {
gotoAndPlay(C);
}
else {
gotoAndPlay(B);
}
and at the beginning of scene 'B' put:
bVisited = true;
solarboi
08-07-2009, 05:18 AM
i paste it but i have this error.
the class or interface 'KeyboardEvent' could not be loaded.
svenjoypro
08-07-2009, 03:27 PM
Are you using AS 3.0? If so, is the script in its own .as file?
solarboi
08-10-2009, 10:29 AM
yap. using AS3.
sorry. i quite a newbie in this. dun mind me asking what do you mean by "the script in its own .as file?"
henke37
08-10-2009, 04:01 PM
Here is a tip: if you don't know what he is talking about, you are not using it. He is talking about a separate class file.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.