Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

+ Reply to Thread
Results 1 to 2 of 2
  1. #1

    Default different key-command on different frame

    Hi,

    I am trying to recreate an interface where the numpad keys 1-9 are involved, as well as buttons for "ok", "back" and "go to start". My problem is that these keys need different actions depending on which frame I'm on. For example, on the first frame, the 1 key takes you to frame 5, but on frame 5, the 1 key should take you to frame 15. And maybe on frame 40, the 1 key means "go to frame 10".

    How do I tell Flash that when on a new frame, the previous key functions should be ignored? Or is there perhaps a better way to solve this?

    My simple code so far:
    stage.addEventListener(KeyboardEvent.KEY_DOWN,fl_K eyboardDownHandler_1);

    function fl_KeyboardDownHandler_1(event:KeyboardEvent):void
    {
    if(event.keyCode == (97)){
    gotoAndStop (5);
    }
    if(event.keyCode == (107)){
    gotoAndStop (10);
    }
    if(event.keyCode == (109)){
    gotoAndStop (1);
    }
    }

    I want to be able to give these keys (and more) different commands when on other frames..

    thx

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    Jun 2009
    Location
    Houston, Tx
    Posts
    485

    Default

    Lol. I just told another guy a good solution, so I'll tell you to.
    http://help.adobe.com/en_US/FlashPla...e-summary.html
    Go here and look around. Type into the search bar "frames" then click the first choice which says "flash.display.MovieClip" which is what you want.
    You'll actually read a little bit (but not too much don't worry!) then come across this nice little property called currentFrame.
    Then you'll read about it and figure out how it is used. Then you'll go to trust google search and type "currentFrame in if statement" then click the first 5 to 10 searches.
    Now, you can probably find your answer without ever having to press a "post" button again. But, in case you were unable to figure it out, just come back and post a different thread, and I'll help you more.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

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
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial