Did you try the mouseEnabledWhereTransparent property?

On 10/26/11 10:43 PM, "dorkiedorkfromdorkt...@gmail.com" 
<dorkiedorkfromdorkt...@gmail.com> wrote:






This is the code I have in the test application. Maybe someone can spot 
something I am missing. I have a button that is the drag initiator and 3 group 
containers (VGroup, HGroup, Group). It can be copied and pasted into a new 
project.


protected function dragButton_mouseDownHandler(event:MouseEvent):void {
                //var sprite:SpriteVisualElement = new SpriteVisualElement();
                var dragSource:DragSource = new DragSource();
                var displayIcon:Image;

                rootDisplayObject = SystemManager.getSWFRoot(this);

                if (useDragManager) {
                    displayIcon = new Image();
                    displayIcon.source = "Button.png";
                    displayIcon.width = 32;
                    displayIcon.height = 32;

                    addEventListener(DragEvent.DRAG_ENTER, dragEnterHandler);
                    addEventListener(DragEvent.DRAG_OVER, dragOverHandler);
                    addEventListener(DragEvent.DRAG_DROP, dragDropHandler);
                    
event.currentTarget.addEventListener(DragEvent.DRAG_COMPLETE, 
dragCompleteHandler);

                    DragManager.doDrag(dragLabel, dragSource, event, 
displayIcon, 0, 0, 1);
                }
}


            private function dragEnterHandler(event:DragEvent):void {
                //var pointTarget:Array = 
systemManager.getObjectsUnderPoint(new Point(event.stageX, event.stageY));
                DragManager.acceptDragDrop(this);
                trace("DRAG ENTER");
            }

            protected function dragOverHandler(event:Event):void {
                targetCandidate = event.target as FlexSprite;
                nameLabel.text = 
NameUtil.getUnqualifiedClassName(targetCandidate);

                /*
                if (targetCandidate is UIComponent
                    && !("hostComponent" in targetCandidate)) {
                    nameLabel.text = 
NameUtil.getUnqualifiedClassName(targetCandidate);
                }
                else if (targetCandidate && targetCandidate.parent is 
UIComponent) {
                    nameLabel.text = 
NameUtil.getUnqualifiedClassName(targetCandidate.parent);
                } */

                trace("DRAG MOVE");
                //nameLabel.text = 
NameUtil.getUnqualifiedClassName(targetCandidate);
            }

            protected function dragDropHandler(event:DragEvent):void {
                var pointTarget:Array = systemManager.getObjectsUnderPoint(new 
Point(event.stageX, event.stageY));
                var length:int = pointTarget.length;
                var label:Label;
                var point:Point;

                trace("DRAG DROP");
                removeDragListeners();


                for (var i:int=length-1;i>-1;i--) {
                    trace(pointTarget[i]);

                    if (pointTarget[i] is GroupBase
                        && !("hostComponent" in pointTarget[i])) {
                        targetCandidate = pointTarget[i];
                        break;
                    }
                }

                if (targetCandidate) {
                    label = new Label();
                    label.setStyle("backgroundColor", 0x424242);;
                    label.setStyle("color", 0xFFFFFF);;
                    label.setStyle("verticalAlign", "middle");;
                    label.setStyle("textAlign", "center");
                    label.text = "";
                    label.width = 120;
                    label.height = 34;

                    targetCandidate.addElement(label);

                    point = label.globalToContent(new Point(event.stageX, 
event.stageY));

                    label.x = point.x+dragOffset;
                    label.y = point.y+dragOffset;

                    label.text = 
NameUtil.getUnqualifiedClassName(targetCandidate);

                }

            }


    <s:HGroup horizontalCenter="0" top="50">

        <s:Group height="100%" >

            <s:Label id="dragLabel"
                     text="Drag me"
                     color="0xFFFFFF"
                     textAlign="center"
                     verticalAlign="middle"
                     fontWeight="bold"
                     height="34"
                     width="120"
                     verticalCenter="0"
                     backgroundColor="0x424242"
                     mouseDown="dragButton_mouseDownHandler(event)"/>
        </s:Group>

        <s:BorderContainer width="400"
                           top="50"
                           right="50"
                           color="#ffffff"
                           backgroundColor="0xe6e6e6">
            <s:layout>
                <s:VerticalLayout/>
            </s:layout>

            <s:Label text="Group" backgroundColor="0" backgroundAlpha=".5" 
width="100%" height="24"/>
            <s:Group width="100%" height="160">
                <s:Rect width="100%" height="100%">
                    <s:fill>
                        <s:SolidColor color="0x554422" alpha=".3"/>
                    </s:fill>
                </s:Rect>
            </s:Group>

            <s:Label text="VGroup" backgroundColor="0" backgroundAlpha=".5" 
width="100%" height="24"/>
            <s:VGroup width="100%" height="160">
                <s:Rect width="100%" height="100%">
                    <s:fill>
                        <s:SolidColor color="0x554422" alpha=".3"/>
                    </s:fill>
                </s:Rect>
            </s:VGroup>

            <s:Label text="HGroup" backgroundColor="0" backgroundAlpha=".5" 
width="100%" height="24"/>

            <s:HGroup width="100%" height="160">
                <s:Rect width="100%" height="100%">
                    <s:fill>
                        <s:SolidColor color="0x554422" alpha=".3"/>
                    </s:fill>
                </s:Rect>
            </s:HGroup>
        </s:BorderContainer>
    </s:HGroup>

On Thu, Oct 27, 2011 at 12:01 AM, dorkie dork from dorktown 
<dorkiedorkfromdorkt...@gmail.com> wrote:
Hi, I'm trying to use drag and drop into a hgroup, vgroup and group but the  
getObjectsUnderPoint is not detecting it!

This is an example,

<group width=200 height=50>
    <button width=100>
</group>


If you move the mouse over the button you will get the button and the group in 
the objects under point array. But if you move the mouse pointer to the right 
of the button but still within the group area you won't get the group!?! I have 
to get the group. What am I doing wrong?








--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to