-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PressMove and PressUp fail to trigger when object disappears #606
Comments
I think what you're running into is the difference between a bubbled event vs a captured event. In the scenario you outlined, you are listening on the stage, but the event target / dispatcher is the circle instance. What you want to do is capture the event on the stage itself (or at least higher up in the display list, where instances aren't being removed). You can do this using the I hope that makes sense. Feel free to reopen if you have more thoughts on this. |
I understand your position. However, it feels unintuitive, especially when you compare it with AS3: var tf:TextField = new TextField();
tf.border = true;
tf.type = 'input';
stage.addChild(tf);
stage.focus = tf;
stage.addEventListener('mouseDown', function(event:Event):void{
trace('mouseDown', event.target); // [object TextField]
stage.removeChild(tf); // removal!
});
stage.addEventListener('mouseUp', function(event:Event):void{
trace('mouseUp', event.target); // [object Stage], it works!
});
stage.addEventListener('click', function(event:Event):void{
trace('mouseUp', event.target); // ... never comes, somewhat justifiably
});
stage.addEventListener('keyDown', function(event:Event):void{
trace('keyDown', event.target); // [object TextField]
stage.removeChild(tf); // removal!
});
stage.addEventListener('keyUp', function(event:Event):void{
trace('keyUp', event.target); // [object Stage], it works!
}); As you can see, AS3 triggers a mouseUp/keyUp, although the initial object is no longer in the display list. I've solved my problem by using |
That reinforces my point though. The |
If you listen for "pressmove" or "pressup" on stage, it shouldn't matter what happens to the object that was under the mouse at the beginning of the drag operation.
Currently, if for whatever reason it ceases to exist, all dispatches also disappear with it.
In case this is a feature, not a bug, please let me advocate against it: imagine you are solely working with the stage. You don't have and don't wish to have knowledge of the objects present there. Let's suppose there's a MovieClip somewhere that has some frame gaps (_off: true). If you're unlucky, you might start your drag on this MovieClip, while it's in an "on" state and then the "off" comes and your unrelated stage drag just stops...
A simple standalone sample:
In the above code, we manually remove the red dot upon "mousedown".
If you started your drag on it, your "pressmove" will be lost.
The text was updated successfully, but these errors were encountered: