Hello and welcome to our community! Is this your first visit?
Register
Results 1 to 8 of 8
  1. #1
    Devoted Veteran


    Join Date
    Aug 2007
    Location
    Michigan
    Posts
    10,329

    Quick Actionscript 2 question

    I want to use the keypress function for a button, but I don't want to use 'up' or 'down' or 'end' or 'enter', I want to use the letter keys. A, B, C, D.

    I figured, because the code for keypress left was:

    on(keyPress "<Left>")

    I could just apply the same thing to the A key..

    on(keyPress "<A>")

    But it gave me the error, Invalid key code. So, how would I make a button activate by pressing A or B or C?
    [center:2mwkv12p][/center:2mwkv12p]

  2. #2
    Regular Member
    Join Date
    Jul 2009
    Location
    There's a branch on the log in the hole in the bottom of the sea.
    Posts
    217

    Re: Quick Actionscript 2 question

    Have u looked up stuff on you tube or google for answers ,is this for a game? i think u gotta make it active by puting it in a selection Like tell me what u did order to recive this erorr?

    Links idk if there thesubject u are looking for)http://www.sitepoint.com/forums/showthread.php?t=624409
    http://www.hypergurl.com/blog/flash/car-game.html
    http://www.actionscript.org/showMovie.php?id=1267(mouse Activated script car game)


    Or somthing from actionscript.org like this http://www.actionscript.org/resources/c ... Tutorials/
    Lifes like a Ocean ull never know whats going to be Put opon the shore "and if u say Ocean fast u said a bad word lol"
    [img]http://**********.com/img/1251832647.png[/img]

  3. #3
    Devoted Veteran


    Join Date
    Aug 2007
    Location
    Michigan
    Posts
    10,329

    Re: Quick Actionscript 2 question

    Quote Originally Posted by SeaFood
    Have u looked up stuff on you tube or google for answers ,is this for a game? i think u gotta make it active by puting it in a selection Like tell me what u did order to recive this erorr?

    Links idk if there thesubject u are looking for)http://www.sitepoint.com/forums/showthread.php?t=624409
    http://www.hypergurl.com/blog/flash/car-game.html
    http://www.actionscript.org/showMovie.php?id=1267(mouse Activated script car game)


    Or somthing from actionscript.org like this http://www.actionscript.org/resources/c ... Tutorials/
    I appreciate you trying to help, but please make sure you know what you're talking about before you post in a help thread..
    [center:2mwkv12p][/center:2mwkv12p]

  4. #4
    Regular Member
    Join Date
    Jul 2009
    Location
    There's a branch on the log in the hole in the bottom of the sea.
    Posts
    217

    Re: Quick Actionscript 2 question

    LMAO Ok So what u trying to do with actionscript?
    Lifes like a Ocean ull never know whats going to be Put opon the shore "and if u say Ocean fast u said a bad word lol"
    [img]http://**********.com/img/1251832647.png[/img]

  5. #5
    Insanity Skype's Avatar



    Join Date
    Apr 2007
    Location
    England
    Posts
    27,397

    Re: Quick Actionscript 2 question

    Quote Originally Posted by SeaFood
    LMAO Ok So what u trying to do with actionscript?
    .... Stop posting here.

  6. #6
    Veteran Enthusiast
    Join Date
    May 2006
    Location
    Midlands, UK
    Posts
    5,638

    Re: Quick Actionscript 2 question

    You use the ASCII codes for letter values in AS2

    http://www.suite101.com/view_image.cfm/942103

    So an example code of an MC using both WASD and arrows to move would be something like:

    Code:
    	// UP        
    	if (Key.isDown(Key.UP) || Key.isDown(87)){
    		if (Yspeed>maxYspeedReverse) {
    			Yspeed -= accel;
    		}
    	}
    	// DOWN             
    	if (Key.isDown(Key.DOWN) || Key.isDown(83)) {
    		//
    		if (Yspeed<maxYspeed) {
    			Yspeed += accel;
    		}
    	}
    	// RIGHT         
    	if (Key.isDown(Key.RIGHT) || Key.isDown(68)) {
    		if (Xspeed<maxXspeed) {
    			Xspeed += accel;
    		}
    	}
    	// LEFT             
    	if (Key.isDown(Key.LEFT) || Key.isDown(65)) {
    		if (Xspeed>maxXspeedReverse) {
    			Xspeed -= accel;
    		}
    	}
    Hope this helped.

  7. #7
    Japanologist Wilio's Avatar

    Join Date
    Dec 2005
    Location
    Somewhere in time
    Posts
    5,561

    Re: Quick Actionscript 2 question

    Make sure to make it for the capitals letter aswell, as the ascii code is different.
    a =/= A.

  8. #8
    Devoted Veteran


    Join Date
    Aug 2007
    Location
    Michigan
    Posts
    10,329

    Re: Quick Actionscript 2 question

    Alright, thanks for all the help.

    I'd appreciate if a moderator would keep this open because I have the feeling I'll need more help later.
    [center:2mwkv12p][/center:2mwkv12p]


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •