ohbeewan
May 26th, 2009, 07:39 PM
I have a display object, and I want to allow users to drag this display object about the screen - no big deal.
Complicating the issue is that, nested in the display object, I have components, and I need their mouse enabled properties to stay true so users can select the items in the components and not drag while doing so.
Normally, in the handler called by a MOUSE_DOWN event, wherein you would apply the startdrag() function to the target of your event, you could apply the startdrag method to the currentTarget, like so:
private static function _dragObj(e:MouseEvent):void
{
e.currentTarget.startDrag();
}
...And this would kill any nested children from being individually dragged, grouping all to be dragged along in the parent display object.
BUT...what if one of your children is a ScrollPane, and you want to allow dragging on the scrollbar without dragging the parent display object? Checking the scrollbar against its super class, I had to do this:
if (e.target is LabelButton)
{
//trace("Scroll, don't drag...");
}
else
{
e.currentTarget.startDrag();
}
I'm not sure if this is the best implementation of this; if anyone else cares to comment, I'd appreciate it! But for anyone who might find themeselves with this problemo, this is one solution...
Thanks!
Complicating the issue is that, nested in the display object, I have components, and I need their mouse enabled properties to stay true so users can select the items in the components and not drag while doing so.
Normally, in the handler called by a MOUSE_DOWN event, wherein you would apply the startdrag() function to the target of your event, you could apply the startdrag method to the currentTarget, like so:
private static function _dragObj(e:MouseEvent):void
{
e.currentTarget.startDrag();
}
...And this would kill any nested children from being individually dragged, grouping all to be dragged along in the parent display object.
BUT...what if one of your children is a ScrollPane, and you want to allow dragging on the scrollbar without dragging the parent display object? Checking the scrollbar against its super class, I had to do this:
if (e.target is LabelButton)
{
//trace("Scroll, don't drag...");
}
else
{
e.currentTarget.startDrag();
}
I'm not sure if this is the best implementation of this; if anyone else cares to comment, I'd appreciate it! But for anyone who might find themeselves with this problemo, this is one solution...
Thanks!