Results 1 to 6 of 6

Thread: Character not moving with Arrow keys in Actionscript 3

  1. #1
    Join Date
    Jul 2010
    Posts
    36

    Character not moving with Arrow keys in Actionscript 3

    My main question over here is how I can make a character that moves with the buttons on the keyboard? I have tried many different coding in Actionscript 3, but nothing works accordingly. So thought that you members would provide some coding for Actionscript 3 which can be useful in making the movement of character. I am trying to make some games in flash, so I need all these things. Please respond to my query as soon as possible. It would be much better for me, if you provide some sample of coding along with an information.

  2. #2
    Join Date
    Dec 2008
    Posts
    202

    Re: Character not moving with Arrow keys in Actionscript 3

    The following steps will definitely help you to create the game in flash.
    1. Make your character (a square is enough). Then convert your 2-character symbol and name it "player".
    2. Go into the actionscript window and enter the following code in the character. Change symbols # and velocity.
      Code:
      onClipEvent (enterFrame) { 
      if (Key.isDown (Key.LEFT)) {// the character moves to the left 
      _x -= # // speed 
      } 
      if (Key.isDown (Key.RIGHT)) {// the character moves to the right 
      _x + = # // speed 
      } 
      if (Key.isDown (Key.DOWN)) {// the character moves down 
      _y + = # // speed 
      } 
      if (Key.isDown (Key.UP)) {// the character moves up 
      _y -= # // speed 
      } 
      }
    3. You can add a background to make more beautiful.

  3. #3
    Join Date
    Oct 2008
    Posts
    167

    Re: Character not moving with Arrow keys in Actionscript 3

    I have reviewed, but what I meant to say was what was the code, but what it means. Something like:
    Code:
    // Declare the variable NoSpeed. Change its value to change the speed of your character. 
    NoSpeed var = 5; 
    
    // We declare a enterFrame event 
    onClipEvent (enterFrame) 
    { 
    // If the key 'left' is left is pressed, then ... 
    if (Key.isDown (Key.LEFT)) 
    { 
    _x -= NoSpeed // This reduces the _x property of our character NoSpeed. 
    } 
    }
    Finally something like this. Then 3000 visit, do not mean 3000 visit useful. A code of character displacement be little more push, and more useful. According to the real beginning is fine, but the 3000 visits were not just beginning. Yes I know they are annoying but you can see it save you problems later.

  4. #4
    Join Date
    Apr 2008
    Posts
    193

    Re: Character not moving with Arrow keys in Actionscript 3

    The following are two methods that can also be useful for you :
    Method 1 : Placing a clip on each side
    Code:
    if (hitTest (_root.pl1)) { 
    _y = -20 _root.pl1._y 
    } 
    if (hitTest (_root.pl2)) { 
    _x = 20 _root.pl2._x 
    } 
    if (hitTest (_root.pl3)) { 
    _y = 20 _root.pl3._y 
    } 
    if (hitTest (_root.pl4)) { 
    _x = -20 _root.pl4._x 
    }
    gropes for the name of the pl

    Method 2 :
    Code:
    meter on Me 
    } 
    if (_x> 550) { 
    _x = 550; 
    } 
    if (_x <0) { 
    _x = 0; 
    } 
    if (_y> 400) { 
    _y = 400; 
    } 
    if (_y <0) { 
    _y = 0; 
    } 
    }

  5. #5
    Join Date
    Jul 2010
    Posts
    36

    Re: Character not moving with Arrow keys in Actionscript 3

    I have tried to use your coding but there are not any movement. I don't know where I am going wrong. Are there any settings that has to be done before using this coding? Since, I have recently started working with the Actionscript 3, I am not having any more knowledge about it. Please guide me by providing proper instructions. I am sure that someone hanging out there can help me.

  6. #6
    Join Date
    Feb 2009
    Posts
    105

    Re: Character not moving with Arrow keys in Actionscript 3

    I have tried to use your coding but there are not any movement.
    Follow the steps mentioned below :
    1. Create a flash file in action script 3.
    2. Backup your project immediately.
    3. Take drawing tools to create the image you want animate keyboard.
    4. Select your design and press (F8) to convert it into a symbol.
    5. Select clip and enter the name of your symbol test (no spaces) and confirm
    6. stay on the selection of your clip that appeared in your library.
    7. All to property and enter the name of the case which is the name of your clip
    8. then click on switch just below and select the clip of the same name.
    9. Maintenance beside occurrence of click action script panel and enter the script
    10. that you were given at the beginning of your clip in post.

Similar Threads

  1. Arrow key does not moving around the web page
    By Hiller in forum Technology & Internet
    Replies: 3
    Last Post: 03-03-2011, 07:15 AM
  2. Where are the arrow keys on the iPad
    By Lael in forum Portable Devices
    Replies: 5
    Last Post: 25-02-2011, 11:01 PM
  3. Problem of arrow keys with VMWARE
    By D_chapple in forum Windows Software
    Replies: 5
    Last Post: 23-12-2009, 11:39 AM
  4. Up/down left/right arrow keys not working properly
    By Nickita in TX in forum Vista Help
    Replies: 2
    Last Post: 06-03-2008, 01:48 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,533,389.24744 seconds with 17 queries