|
-
Pumpkin Carving 2008
 Originally Posted by Fall_X
Yeah already found it meanwhile, not much more info indeed.
I just noticed another prob, which should also occur with the senocular class you use (mine is very similar, but I wrote it before he posted his class way back when). When you right click, the deactivate event isn't called, so keys can still get stuck. I'm having trouble finding a on-contextmenu event, but it's probably in there somewhere. Any ideas would be appreciated.
Maybe?
Code:
stage.addEventListener(MouseEvent.RIGHT_CLICK, clearKeys);
private static function clearKeys(event:MouseEvent):void {
keysDown = new Object();
}
Should clear any keydef's the class is holding onto if you right click, but it's off the top of my head because I don't have time to test it.
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
 Originally Posted by fvidal
Got the same problem, just find why. Focus on a object (sprite, mc, whatever) that you remove from stage and got garbage collect. Boom, loose stage focus.
OMG, thank you very much.
This really helped me to fix my problem .
Now after removeChild() I'm setting stage.focus = stage; and I know why it works which is important for me
-
I had this problem earlier today and found the best way around it was..
PHP Code:
//add a listener to check for focus loss
stage.addEventListener(FocusEvent.FOCUS_OUT, focusOut);
//reset focus when lost
public function focusOut(e:FocusEvent):void
{
stage.focus = stage;
}
-
Sorry for digging up this old thread, but I just ran into this issue, and I think there is another way to fix it, that might be better in most cases:
The flash component like a button or whatever seems to capture the event and stops its propagation. So it will never bubble up to the stage Object.
But don't forget: An event in Actionscript has 2 phases: the bubble phase, and the capture phase.
First, the event goes down from the stage to the element that is the target of the event. Then, it bubbles up again to the stage.
So just put your eventlistener in front into the capture phase, and you will be fine
Code:
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.keyDown, true);
The true is the useCapture param.
Also, if your "this" might get removed from stage, it is good practice to make the event listener a weak reference, so the object can be collected by the garbagecollector:
Code:
this.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.keyDown, true, 0, true);
-
im having the same problem, im gonna see if stage.focus=stage fixes it...
edit*** yup adding that before I call the creation of any other sprites in my enterframe function fixes all problems...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|