A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: I'd like to change my code from using the left key=previous frame/ right key= next fr

  1. #1
    Junior Member
    Join Date
    Oct 2007
    Posts
    11

    Thumbs up I'd like to change my code from using the left key=previous frame/ right key= next fr

    I'D LIKE TO CHANGE MY CODE FROM USING THE LEFT KEY=PREVIOUS FRAME/ RIGHT KEY= NEXT FRAME TO

    ANY KEY=NEXT FRAME. HERE IS MY CODE. PLEASE HELP ME OBI WAN KENOBI, YOU'RE MY ONLY HOPE:

    stop(); stage.addEventListener(KeyboardEvent.KEY_DOWN, changeSection); function changeSection(event:KeyboardEvent):void { switch (event.keyCode) { case Keyboard.RIGHT : nextFrame(); break; case Keyboard.LEFT : prevFrame(); } }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Perhaps not the best way, but all I can think of right now
    PHP Code:
    stop();

    stage.addEventListener(KeyboardEvent.KEY_DOWNpressAnyKey);

    function 
    pressAnyKey(e:KeyboardEvent)
    {
        
    stage.removeEventListener(KeyboardEvent.KEY_DOWNpressAnyKey);
        
    stage.addEventListener(KeyboardEvent.KEY_DOWNpressSingleKey);
        
    nextFrame();
    }
    function 
    pressSingleKey(event:KeyboardEvent):void
    {
        switch (
    event.keyCode)
        {
            case 
    Keyboard.LEFT :
                
    stage.removeEventListener(KeyboardEvent.KEY_DOWNpressSingleKey);
                
    prevFrame();
                break;
        }


  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    The last post only works with two frames, I suspect you have more so try
    PHP Code:
    stop();

    stage.addEventListener(KeyboardEvent.KEY_DOWNpressAnyKey);

    function 
    pressAnyKey(event:KeyboardEvent)
    {
        switch (
    event.keyCode)
        {
            case 
    Keyboard.LEFT :
                
    prevFrame();
                break;

            default :
                
    nextFrame();
        }


Tags for this Thread

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center