A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Keyboard navigation problem

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    1

    Keyboard navigation problem

    Hi
    I am new to actionscript. I was trying to make a slide show frame by frame. I have my main timeline with the following code in first frame.

    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_changeSlide);
    function fl_changeSlide(evt:KeyboardEvent):void
    {
    if (evt.keyCode = 37) // LEFT
    {
    gotoAndStop(this.currentFrame-1);
    }
    else if (evt.keyCode == 39 || evt.keyCode == 32)
    {
    gotoAndStop(this.currentFrame+1);
    }
    }

    In the third frame I am trying to load an external swf by clicking a button 'rrbutton' and unload the same when the user clicks left arrow.

    var loadit = new Loader();
    function ack(evt.keyboardEvent):void {
    if(evt.keyCode == 37)
    {
    loadit.unloadAndStop();
    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_changeSlide);
    }
    }
    function newvid(event:MouseEvent) {
    stage.removeEventListener(KeyboardEvent.KEY_DOWN, fl_changeSlide);
    addChild(loadit);
    load.load(new URLRequest ("myvideo.swf"));
    this.addEventListener(KeyboardEvent.KEY_DOWN, ack);
    }

    rrbutton.addEventListener(MouseEvent.MOUSE_DOWN, newvid);

    The external swf loads on clicking the button and unloads when left arrow is pressed and the main time line frame appears. But thereafter the keyboard navigation in the main timeline(through function fl_changeSlide) is not working properly.

    Can someone help. Thanks in advance.

    Sasi

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Use [code] tags to post code.

    Define "not working properly". Are you getting errors? Is it doing nothing at all? Going to the wrong frame?

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