Keys pressed or not pressed

Hi
I am struggling a bit with keys on the keyboards controlling a movieclip to happen.
Ive got a person moving when pressing right and left, and a movieclip with three frames: First frame is a movieclip with the person standing still, looking bored. The second frame is the person moving right, and the third frame is the person moving left.
This is the code that Ive inserted into the persons actions on scene1:
if (Key.isDown(Key.RIGHT)) {
_x += speed;
this.gotoAndStop(2);
_xscale = +scale;
if (Key.isDown(Key.LEFT)) {
_x -= speed;
this.gotoAndStop(3);
_xscale = -scale;
this code works alright accept that when the keys are not pressed it doesnt stand still, the legs are still moving, so I tried to include this code aswell:
if (!Key.isDown(KEY.RIGHT)) {
       _root.char.gotoAndStop(1);
    if (!Key.isDown(KEY.LEFT)) {
       _root.char.gotoAndStop(1);
this makes the person standing still when not pressed but not moving the legs when turning right and left.
What am I doing wrong, any ideas?
Thank you for any help.

use:
if (Key.isDown(Key.RIGHT)) {
_x += speed;
this.gotoAndStop(2);
_xscale = +scale;
} else if (Key.isDown(Key.LEFT)) {
_x -= speed;
this.gotoAndStop(3);
_xscale = -scale;
} else {
this.gotoAndStop(1);
(and, do you really want that scaling?)

Similar Messages

  • My Wireless mac keypad has stopped properly working. The keys sometime do not correspond to the result, or a a simultaneous duel actio, for example when the delete button is pressed the. Ursor does go backwards, but it also turns the sound up. Any ideas?

    My Wireless mac keypad has stopped properly working. The keys sometime do not correspond to the result, or a a simultaneous duel actio, for example when the delete button is pressed the. Ursor does go backwards, but it also turns the sound up. The keyboard is properly connected to the computer, and the battery life is up in the nineties.
    Help please !!!!

    Hi, thankyou for your response. Can I just confirm that you mean turning the computer on and off again, or re-booting the whole system. If it is the first I have already turned the system on and off, with no luck.
    Regards

  • Call do not route to operator when users do not press any key

    We have a new CUCM platform with Cisco Unity ver 9.1.2TT1.11900-2TT1.
    We configured system handlers and and all "caller input" options runs good but when callers do not press any key the call goes to "nowhere", instead of going to Operator (default behavior).
    Do you have any idea on what could be misconfigured here, or what should be configured to solve this problem??
    Thanks a lot
    Enrique

    Sorry for my last "wrong answer" .....You (again) was right, I had a bad configuration on "after greeting" setting..i had:
    "Call Action: Take message".
    I changed to " User with Mailbox pointing to recepcionist VM.
    Jaime thanks a lot.
    Enrique Villasana

  • Again me with a keyListener question, second alt press does not register

    hey, i noticed something was off with the behavior of the application i wrote, and then i checked with the KeyEventDemo.java at http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
    and i found out that i was correct, when pressing and releasing the Alt key it registers pressed and released, but when pressed the second time only released is registered.
    since the alt key behaves different then the rest of the keys, i'm sure there is a reason for it, can any one tell me why, or if can work around it??
    thanks,
    Adam.

    I was not trying to insult you, but more to break the ice since it felt like you were "talking down" towards me,
    camickr wrote:
    ok, its the second time you recommend to use the key binding, So why are we wasting our time having to recommend it again? You where given the link to the tutorial the other time as well.
    any good explanation as for why? a) you just found a reason
    b) thats why you read the tutorial
    I mean my application is a small 3d game a) what does small or large have to do with anything? The best design is the approach you should use.
    b) how do we know that from the question?
    Our approach is to suggest the best approach that we know. This approach may or may not be appropriate, that is why you read the tutorial and make up your own mind. Of course all Swing components use KeyBindings. Many of them like the text components or JTable will bind 20 different keys. it's not that i didn't take your advice from the first time you gave it, i read the tutorial of both keyListener and keyBinding, and browsed through the documentation of them both, but still a few things were not clear to me as to the efficiency of a wider usage of keys that's all.
    and btw I have the utmost respect to you guys and what you do, and i hope we can still get along, so thank you for your help, i'll menage from here.

  • My MacBook Pro keyboard is giving trouble. 0,p,;,/ and the enter key needs to be pressed several times before registering. Help me please??

    My MacBook Pro keyboard is giving trouble. The 0,p,;,/ and the enter key, needs to be pressed several times before registering. Help me please??

    If you are still under warranty and/or have AppleCare, call them.  Let them deal w/it.  Out of warranty, your keyboard may need cleaning.  Use a vacuum hose or a can of compressed air to get the dirt out from under the keys.  For instructions to remove the keys if it comes to that check out the following websites:
    iFixit
    TakeItApart
    Search YouTube for Macbook Pro “How To” tutorials.
    If you do not want to DIY, take your MBP to your local AS or an AASP.

  • HT1386 How to take screen shot in 4s , help says hold the home+wake up key but Shen I press Siri comes up

    How to take screen shot in 4s , help says hold the home+wake up key but Shen I press Siri comes up

    Hold the on/off and home buttons for about 1 second, then release simultaneously.

  • I have forgotten which key I need to press to offer the option of switching from Windows 7 to Mac os. Can anybody help?  Many thanks.

    Can anybody advise me on which key I need to press on start up to be given the option of switching from Windows 7 to Mac OS?
    Many thanks.
    John

    "option"

  • The power button will not press, it's stuck

    The power button will not press, it's stuck. I need help.

    Believe it or not, if the power button is not related to a more serious issue. You can take it to an Apple Store, remember to set a genius appointment at http://www.apple.com/retail/,  and get it unstuck for free, or call 800-676-2775 for help. If its more of an issue, they will tell you at the store and how much it will cost to repair if your device isn't under warranty. Also, you can trade it in for credit toward a new ipod touch. Hope this helps.

  • I recebtly bought an app (FIFA 12) now every time i play a match after the match it does not save an just goes to the home page without warning and i have to start all over again and no i did not press the home button. plz help

    i recebtly bought an app (FIFA 12) now every time i play a match after the match it does not save an just goes to the home page without warning and i have to start all over again and no i did not press the home button. plz help

    You can't gift it, gifting can only be done from within the store, not from within your library.
    Puchases are considered final but you can try the 'report a problem' link to contact iTunes Support and see if they will refund or credit you : http://reportaproblem.apple.com
    If the 'report a problem' link doesn't work then you can try contacting iTunes Support via this page : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption

  • HT201586 What combinations of keys I have to press to insert the @ symbol on a MacBook Air?

    What combinations of keys I have to press to insert the @ symbol on a MacBook Air?
    Thanks,

    It depends on the keyboard layout, but is often Shift and 2.
    (121856)

  • I cant downlad music onto my ipod, i looked at the tutorial videop but the icon i need to press is not there. am i forgetting to do something?

    i cant downlad music onto my ipod, i looked at the tutorial videop but the icon i need to press is not there. am i forgetting to do something?

    Are you following the instructions here:
    iTunes: Syncing media content to iOS devices and iPod
    Have you synced music from this iTunes library to the iPod before?
    What happens when you try to sync?

  • Notes in the iPads fly, i can not open them immediately after pressing the notes a black screen appears and disappears

    notes in the iPads fly, I cannot open them immediately after pressing the notes a black screen appears and disappears

    Quick update, the duplicate of the comic-con episode downloaded succesfully, and so has the first episode of Supernatural season 8. Blue dots appear to their left in the library.
    All the Vampire Diaries episodes (except the bonus comic-con double) have vanished, but I paid for them !
    They're not anywhere on my harddrive either.
    Which is new by the way, this is a new MacbookPro, literally set it up today.
    So it would seem this is a case of purchased and pseudo-downloaded episodes that ended up beinge gobbled up by some iTunes black hole, leaving me with no money, and no episodes.
    Need help, confirmed.

  • Double touch (not press) the home button!?!?

    With any app open on the screen double touch (not press) the home button. It slides the app down to show a blue blank screen. Does anyone know what this is for

    Hello,
    This function is called "Reachability" (also known as 1-handed mode).
    It allows a user to control the phone with one hand.
    If you wish to turn it off: go to settings, go to accessibility, turn it off.
    Regards,
    Stef Heck

  • Nautilus terminal can not press / and s!

    nautilus terminal can not press / and s,it auto open location or search?how can i do it?

    Try force quitting the Music app: double-tap the home button, locate Music in the list at the bottom, tap and hold it until it wiggles, tap to close it, finish by tapping the home button.  Reopen Music and see if it works now.

  • RSS screensaver: I can not press '1' to read article on AZERTY keybord

    Hi,
    When I use the RSS screensaver, I can not press '1' to read the article. I am using a AZERTY keybord on my MacBook and when I try to press '1', the screensaver stops and nothing else happens. I suppose it is because I need to press shift to enter a number...
    I already tried to use shift-lock before starting the screensaver. Same issue...
    Any ideas?
    MacBook   Mac OS X (10.4.7)  

    Anybody ?

Maybe you are looking for