Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

Using the page-up and page-down key functions to move scenes

I am extremely rusty when it comes to Flash CS3 (I'm using AS2).  I have several scenes, each one with a next/previous button.  I would really like to be able to set the Page-up and Page-down keys, to do what the buttons do when they are clicked.

Hope that makes sense.
0
Andy Brown
Asked:
Andy Brown
  • 2
  • 2
1 Solution
 
moagriusCommented:
you can use the attached snippet as a starting point.  note that it won't work in "Test Movie" mode since Page Up and Page Down have API instructions - preview in HTML to enable visible functionality.

the code should go in the action's panel of frame 1 of the main timeline
var listenerObject:Object = {
	onKeyDown : function(){
		switch(Key.getCode){
			// page up
			case 33 : 
			  trace("page up pressed");
			  gotoAndPlay("someScene");
			  break;
			// page down
			case 34 : 
			  trace("page down pressed");
			  gotoAndPlay("anotherScene");
			  break;
		}
	}
};
Key.addListener(listenerObject);

Open in new window

0
 
moagriusCommented:
oops...  Key.getCode should be Key.getCode()  - note the parens.
var listenerObject:Object = {
        onKeyDown : function(){
                switch(Key.getCode()){
                        // page up
                        case 33 : 
                          trace("page up pressed");
                          gotoAndPlay("someScene");
                          break;
                        // page down
                        case 34 : 
                          trace("page down pressed");
                          gotoAndPlay("anotherScene");
                          break;
                }
        }
};
Key.addListener(listenerObject);

Open in new window

0
 
Andy BrownAuthor Commented:
That's great i'll give it a try in the morning.

Thanks for your help.
0
 
Andy BrownAuthor Commented:
Perfect - that sent me nicely on my way.

All the best.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now