A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: I'm stumped

  1. #1
    Junior Member
    Join Date
    Jul 2010
    Posts
    3

    resolved [Resolved]I'm stumped

    I've been teaching myself for over a year now and am pretty good at finding my mistakes and spending as much time as it takes solving a problem but I need some help with this very strange problem.

    The problem:
    The game starts at a title screen, a button is clicked with the mouse and you are brought to the start of the game. The keyboard does not respond unless the game is clicked on once with the mouse.

    More detail:
    The button is created through a method of the screen that contains it, the method is called in the contructor of the document class, the framework. The button has one mouse.click listener that dispatches a custom event to the framework removing the title screen and running a switch statement that adds and initializes the game.

    Things I've tried:
    - A trace statement in the constructor of the object that registers the event listeners shows that the listeners are there. But a trace statement in the event handler shows no response.

    - Registering the event listeners and putting the handlers in another object shows no change, including in the document class where a trace statement works when the title screen is up, does not work after the button is clicked until the the game is clicked once.

    - Using different mouse events to trigger the event dispatcher in the button class shows no change.

    What makes this problem go away (the strange part):
    Turning off buttonmode and removing the textfield created inside the button
    eliminates the problem and the controls kick right in when the game starts.

    If any can offer some insight I'd really appreciate it, I can't seem to find any solution for this or any similar problem so I'm guessing it's some small detail I'm missing.
    Last edited by Mikroft; 01-11-2011 at 06:43 AM.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Sounds like your swf is losing keyboard focus because the focus is still on the button or textfield you clicked that disappeared. Try manually setting stage.focus to something that's on-screen.

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    3
    that worked:

    trace(stage.focus);
    [object TextField]

    just getting the focus off the textfield worked,
    stage.focus = null;

    thanks and cya

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