A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: KeyboardEvent cannot reactive after gotoAndPlay

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    1

    KeyboardEvent cannot reactive after gotoAndPlay

    Hello I am Kamen Rider FR,

    I'm still a beginner in programming ActionScript 3.0,

    I had a problem with KeyboardEvent in ActionScript 3.0,

    I created a simple shooting game, the game has 2 Frame,

    1. Title Game (Frame 1)


    2. Game Playing (Frame 2)


    The problem is in Frame 1 when Button is clicked playinggame

    then switched Frame to Frame 2 where the game takes place where the user can move the aircraft by using the keyboard, (Left Arrow, Up Arrow, Right Arrow & Down Arrow).

    But when a keyboard button is pressed, KeyboardEvent not react at all, and aircraft can not be controlled.

    Even more bizarre when the stage at the click KeyboardEvent can react and aircraft can be controlled.

    The question is how to keep the button is clicked playinggame in Frame and the Frame 2, the aircraft can still be controlled using the keyboard

    I beg the solution of the comrades in the forum, the following file code themselves


    this link of my code :
    http://www.mediafire.com/?39ivuqcrr5k6b9u#1


    Thank you for Help

  2. #2
    Moderator enpstudios's Avatar
    Join Date
    Jun 2001
    Location
    Tampa, Fl.
    Posts
    11,282
    It sounds like the object you are trying to move is losing focus when your timeline changes frames.

    Try: stage.focus = yourMovieClipNameHere;

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    If you attach your eventListeners to an object in frame 1 and then frame 2 has a new keyframe, the object from frame 1 will be destroyed and a clone of it is created (with no event listeners) on frame 2.

    In order for your listeners to survive, you need to make sure that object doesn't get destroyed and remade in a keyframe, or you can move your eventListeners to the second frame.
    Please use [php] or [code] tags, and mark your threads resolved 8)

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