Keyboard Event Isn't Working, and don't know why.

I am creating a game where you have to use the up and down buttons on the keyboard to avoid movie clips. For some reason it won't register when i press the keys down.
If anyone has any insight as to why it would be greatly appreciated.
Here is my code:
stop();
var Santas:Number = 5;
var keyDown1:Boolean = false;
var keyUp1:Boolean = false;
stage.focus = this;
function randomValue()
    return Math.round(Math.random() * 500);
stage.addEventListener(Event.ENTER_FRAME, loop);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownEvent);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpEvent );
function keyDownEvent(myevent:KeyboardEvent)
    if (myevent.keyCode == Keyboard.UP)
        keyUp1 = true;
    if (myevent.keyCode == Keyboard.DOWN)
        keyDown1 = true;
function keyUpEvent(myevent:KeyboardEvent)
    if (myevent.keyCode == Keyboard.UP)
        keyUp1 = false;
    if (myevent.keyCode == Keyboard.DOWN)
        keyDown1 = false;
function loop(myevent:Event)
    score_txt.text = "Santas Left: " + String(Santas);
    cane1_mc.x +=  4;
    if (cane1_mc.x > 550 && cane1_mc.y > 0)
        cane1_mc.x = -10;
        cane1_mc.x = randomValue();
    cane2_mc.x +=  3;
    if (cane2_mc.x > 550 && cane2_mc.y > 0)
        cane2_mc.x = -10;
        cane2_mc.x = randomValue();
    cane3_mc.x +=  3;
    if (cane3_mc.x > 550 && cane3_mc.y > 0)
        cane3_mc.x = -10;
        cane3_mc.x = randomValue();
    lake1_mc.x +=  4;
    if (lake1_mc.x > 550 && lake1_mc.y > 0)
        lake1_mc.x = -10;
        lake1_mc.x = randomValue();
    lake2_mc.x +=  3;
    if (lake2_mc.x > 550 && lake2_mc.y > 0)
        lake2_mc.x = -10;
        lake2_mc.x = randomValue();
    mountain_mc.x +=  3;
    if (mountain_mc.x > 550 && mountain_mc.y > 0)
        mountain_mc.x = -10;
        mountain_mc.x = randomValue();
    if (keyDown1 && santa_mc.y > 351.10)
        santa_mc.y -=  2;
    //trace(keydown)
    if (keyUp1 && santa_mc.y < 25.10)
        santa_mc.y +=  2;
    //trace(keyup)
    if (santa_mc.hitTestObject(cane1_mc))
        Santas--;
        cane1_mc.x = -550;
    if (santa_mc.hitTestObject(cane2_mc))
        Santas--;
        cane2_mc.x = -550;
    if (santa_mc.hitTestObject(cane3_mc))
        Santas--;
        cane3_mc.x = -550;
    if (santa_mc.hitTestObject(lake1_mc))
        Santas--;
        lake1_mc.x = -550;
    if (santa_mc.hitTestObject(lake2_mc))
        Santas--;
        lake2_mc.x = -550;
    if (santa_mc.hitTestObject(mountain_mc))
        Santas--;
        mountain_mc.x = -550;
    if (Santas == 0)
        gotoAndStop(3);

That doesn't change anything.
Now don't know if this has anything to do with it but i have the flash layed out with 3 frames one for a intro screen and another for when you run out of lives and they both have buttons on them.

Similar Messages

  • Help!(confused face) I'm new with flash and don't know why the timers don't work like i would expect

    I'm new with flash and don't know why the timers don't work like i would expect.  In VB.NET timers are how you move stuff, but it doesn't look like they are ideal for moving stuff in flash at all (really slow).  I'm making a game in which you throw a ball around the screen. i am using a timer to get the ball to move. this doesn't work well for 2 reasons; 1: the ball jumps alot, and 2: the timer should eventually run out of time.  If anyone can help, i'd be thrilled cus this is my first post here, so yeah

    Timing for movement would be more often dealt with using something that operates at the frame rate of the file.  The ENTER_FRAME event is usually selected for this purpose.
    stage.addEventListener(Event.ENTER_FRAME, moveBall);
    function moveBall(evt:Event):void {
         // your positioning code
    You could use a Timer to control when to stop the listener from being active.

  • HT204384 my sd slot card of my mac don't work . i don't know why! can you help me

    my sd slot card of my mac don't work . i don't know why! can you help me

    If it doesn't work with any sd card you insert into it then you can try a smc reset and a pram reset but if that doesn't work then the slot has failed. the only way to get that fixed is to replace the main circuit board, the logic board, which is very expensive. That is unless your mac still has a warranty on it then it would be free.
    If you have no more warranty then just buy a sd card reader that connects to the computer by usb port.

  • I am unable to open Organizer or Photo Editor this morning of elements 12 and don't know why.

    I am unable to open Organizer or Photo Editor in elements 12 this morning and don't know why.  Any ideas??

    OK,
    Good to hear that you are running at the moment.
    The causes for organizer and the editor to stop working are usually different. For both to be affected, I would tend to suspect disk space problems. Probably a good idea to check that you have plenty of free space.
    Please let us know if you have problems again and we can try troubleshooting.
    Brian

  • I have a mac os x 10.6 and don't know why I am not able to update to '09. Help please!

    I have a mac os x 10.6 and don't know why I am not able to update to '09. Help please!

    It is, but only when installed from an iWork 09 DVD(places such as Amazon and eBay may sell these) and not from the Mac App Store.
    (81103)

  • I can't entered in iTunes Store.not working and i dont know why

    I can't entered in iTunes Store.not working and i dont know why

    "Error 11222"
    Apple is investigating reports of this issue. Proxies, certificate issues, or your Internet service provider may be the cause of this issue.
    From:
    http://support.apple.com/kb/TS3297

  • Hello, I want to change my ICloud storage (to reduce it) and don't know why it doesn't allow me.. need some help!

    So 2 weeks ago I change my storage for mistake and then I realized that It was unnecesary to have 20 GB so I tried to go back with the purchase but when I put 5 GB back i can't press "OK" button.. don't know why...
    I attach an screenshot
    Tnks

    It will revert to the 5GB allowance when your current purchase ends.

  • HT3702 I have a charge of .36 on my account and don't know why

    I got a charge for .36 cents and don't know why

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • My iPod nano said it couldn't download a song and don't know why

    I was downloading my MC Solar songs to my iPod and it was able to download all but one song and said it wasn't able to download it. I don't see anything different about that song and I don't know why it would download the others but not just this one song. Can anyone offer any help?

    Did it give an error message? If so what did it say?

  • Gx 740 not working - but don't know why!

    Hi everyone, this is my first post and I apologise if I've put this in the wrong forum. If so, please feel free to move it.
    I have an MSI GX740 and recently it stopped working and I have no idea why and was hoping someone here could help me try and discover the source of the problem at least so that I know what I'll be looking at in terms of expense to get it fixed. I'll try to give as much as detail as I can.
    I had no problems with the laptop itself (no history of crashes or anything) until one morning when I went to turn it on, and it wouldn't boot up. The lights came on and the machine whirred as usual, but no POST screen appeared. So I turned it off and tried again, but to no avail. So, after looking online (in the library) and using all the tricks of unplugging the battery and adapater etc. I decided to leave it for a while. So I tried it the next day, and it managed to boot all the way to the dekstop. When I was on the desktop I managed to play a music file, move some files and delete some other files, but when I went to play a game, the game wouldn't run. So I used CTRL-ALT-DEL to end the task, and tried a different game, and the screen went black (as it always does before this games starts) but it just stayed black so I turned it off, and couldn't boot again. This suggested a video card problem, but the first game I tried to run was Championship Manager 2000/2001 which hardly uses graphics at all! (That's not a typo, I downloaded the old game through freeware).
    So, again after reading internet resources, I waited a while and turned on the laptop and got to the POST screen. I pressed DEL to enter setup and reset all the bios settings, but this had no effect. So then I restarted and tried the F3 OS recovery method. Whenever I do this though I either get a message that says "reagentc.exe FALSE" and it keeps going but nothing happens at the end or, more commonly, I get a BSOD with a message about IRQL_LESS_THAN_OR_EQUAL or something along those lines (I'll make a proper note of it later).
    So basically, I now have no idea what's causing this, and I am going to get it fixed, but having no knowledge of the cause I have no idea how much it's going to cost, or if it's something i can even try myself (I don't have an encyclopedic knowledge of computers, but I have installed some PC components myself in the past.)
    I've read that the reaganetc.exe message means I need to reinstall Windows 7 completely, but I don't have the Windows 7 disc (I travel a lot and think it's been lost in transit, or I just didn't get one in the first place - I genuinely can't remember). I spoke to a guy in a computer shop today who said that msi should be able to sell me a recovery cd which might solve the problem and would cost something like 20 AUD and if it doesn't work, I've only wasted 20 bucks, rather than the 300 bucks it costs to buy Windows 7 itself, when that might not even be the problem.
    But I've also been reading that the BSOD message suggests it may be a hardware problem, but I have no idea which one would be failing.
    Because the laptop is clearly not working in some aspect, I don't mind opening it up and having a go myself as the warranty is more than likely void anyway, as I have a chip in my casing (bottom left of the screen) so MSI would more than likely say the problem has been caused by misuse. (I didn't drop the laptop, but the bag I have it in doesn't hold it very securely, and I do travel a lot so it was just general wear and tear that caused it. I'll be buying a proper laptop bag when I get this one fixed!!)
    My current status is that if I leave it for a while I can get it to the POST screen, but because of my previous efforts to recover the OS (which meant wiping the C drive) I can no longer get into Windows. If anyone has any ideas at all I'd be so grateful to hear them. If you need any more info I'll gladly provide it. However, I am based in Australia so please accept my apologies if my replies take a long time due to the time difference.
    The laptop is an MSI GX 740 as I said, so these are the specs:
    http://laptops-specs.blogspot.com/2010/06/msi-gx740-specifications.html
    Thanks in advance

    I also had the same problem. I have the A6200 laptop.The msi recovery on the hard drive failed with "reagentc.exe false" error. Same thing with the recovery dvd i had created earlier. same thing with the recovery dvd that bought from MSI. I tried installing Win7 from a installation dvd which failed as well. Then i ran a memtest86 and found out that one of the memory sticks was bad. you could also run the memory diagnostic on the Windows Recovery DVD (WRE) as well. So i just took out the bad memory and the MSI recovery worked flawlessly. I wish i had realized that this was due to bad ram. i wasted money buying a new recovery dvd from msi and wasted days trying to fix this. So if you are getting the reagentc.exe error check your memory. I am not saying this is the only source of the problem, but it could be and i haven't come across anyone suggesting this anywhere else. Also the reason i decided to do a clean install in the first place was because windows kept crashing randomly, which should have made me realize that this was a memory related issue. I hope this helps. 

  • I lost my HOME and REFRESH buttons and don't know why. Since I can't have them anymore please tell me in detail how I get rid of Mozilla Foxfire and let me know what all I'm going to lose in the process. Thanks, Neil

    I have used Mozilla Firefox for almost a year and it was good. Now I make on stupid mistake by upgrading to the new version and I lose my Home button, Refresh button and I don't know how many other buttons.
    Since I can't have WHAT I USED TO HAVE please explain in detail how I rid of Mozilla Firefox and what I'm all going to lose in the process.

    The home icon by default has moved to the right hand side of the navigation toolbar.
    In Firefox 4 by default the Stop, Go and Reload (Refresh) buttons are combined and attached to the right hand edge of the location bar.
    When you are typing in the location bar it will show the Go button. When a site is loading it shows the Stop button. At other times it shows the Reload button.
    If you want separate buttons stop/go/reload buttons, or want to move the home button, right-click on a toolbar and choose Customize, you can then drag and drop the buttons and place them elsewhere. If you place them in the order "Reload-Stop" on the right hand edge of the location bar they will be combined again. For more details on customizing the toolbar see https://support.mozilla.com/kb/How+to+customize+the+toolbar

  • Ipod not working and I dont know why?

    Can someone please help me?
    I closed my Ipod cause none of my apps were opening and i closed it and now all its doing is this.. (picture on the bottom) ; It has been doing this for over 20 minutes and i dont know what to do, can anyone help me?
    something like the picture but without the apple on the top just the circle thing.
    please please please help me

    Try here:
    iOS: Not responding or does not turn on
    If not successful and you can't turn the iPod fully off, let the battery fully drain. After charging for at least an hour try again.

  • Sound does not sync up with the video and don't know why.

    When I converted the video's, the sound and video are perfect, but when I add them to itunes, the sound is off with the video. Anyone know why and how to fix it?

    read my post

  • I can't get command+j the joining option to work its giving me an error and don't know why..new at illustrator

    please help. Im in vector graphics and I'm very new to all this adobe stuff anything helps

    Caitlyn,
    You may have multiple coinciding Anchor Points at (at least) one path end. You may Direct Select the (top) Anchor Point and move it a little (preferably by a specific value) to see whether something hidden shows up; you can just Undo or move it back.
    Depending on version you may also (try to) just normally Select the two paths and Cmd+J.

  • I can no longer access the itunes store and don't know why.the browser bar at the top loads half way and then stops. Any ideas?I am on windows 7.Thanks.

    browser bar at the top loads half way and then stops. Any ideas?I am on windows 7.Thanks.

    it seems to work when you reset the port
    try this only after you've made sure that any antiviral/firewall software isnt blocking iTunes and the internet connection settings are fine
    1. go to windows, accessories and right click on command prompt and run as administrator
    2. type in netsh winsock reset (i know sounds ridiculous but it works type WITH SPACES) and press enter
    3. Message saying "winsock reset successful now reboot your computer"
    4. restart your computer, and open iTunes..backup should run much smoother and faster
    5.Click on iTunes store might be working now

Maybe you are looking for