Flex 4.6 Everything draggable

235 views Asked by At

I just made my itemrenderer (which is in a viewstack) draggable, but now I have the following problem, namely I can drag EVERYTHING in my viewstack. I only want to drag the whole itemrenderer or a part of it (cover). At this moment I can also drag the whole navigatorcontent and the scrollbar (!). Does somebody has a solution for my problem? thx in advance!

(example of the faults and the way it has to be --> http://d.pr/i/hjti )

<fx:Script>
    <![CDATA[
        // imports
        import mx.collections.ArrayCollection;
        import mx.controls.Alert;
        import mx.controls.Alert;
        import mx.core.DragSource;
        import mx.managers.DragManager;
        import mx.events.DragEvent;
        [Bindable]
        private var quantity : int = 0;
        private function initiateDrag(event:MouseEvent):void {
            var dragInitiator:List = event.currentTarget as List;
            var source:DragSource = new DragSource();
            source.addData(dragInitiator,"cart");
            var proxy:Image = new Image();
            proxy.source = event.target;
            proxy.width = 120;
            proxy.height = 150;
            proxy.x = (mouseX - (proxy.width * 3.25));
            proxy.y = (mouseY - (proxy.height * 3.25));
            DragManager.doDrag(dragInitiator, source, event, proxy);
        }
        private function dragEnterHandler(event:DragEvent):void {
            if (event.dragSource.hasFormat("cart")){
                DragManager.acceptDragDrop(event.currentTarget as Image);
            }
        }
        private function dragDropHandler(event:DragEvent):void{

            Alert.show("Gift added to your favorites");
        }
    ]]>
</fx:Script>

<mx:ViewStack id="myStack" width="100%" height="241"  change="doFilter();" creationComplete="doFilter()">

        <s:NavigatorContent label="Shooter"   >

            <!-- hier zet je een tussenruimte van 5-->
            <s:List left="10" top="7" width="100%" height="237" borderColor="#CC0000"
                    borderVisible="false" contentBackgroundAlpha="0.0"
                    dataProvider="{GamesLijst}" itemRenderer="itemrenderers.GameRenderer"
                    rollOverColor="#0492B1" dragMoveEnabled="true" dropEnabled="true" mouseDown="initiateDrag(event)">
                <s:layout >
                    <s:TileLayout horizontalGap="10" verticalGap="10" horizontalAlign="left" verticalAlign="top"/>
                </s:layout>
            </s:List>
        </s:NavigatorContent>
        <s:NavigatorContent label="Sport">
            <!-- hier zet je een tussenruimte van 5-->
            <s:List left="10" top="7" width="100%" height="231" borderColor="#CC0000"
                    borderVisible="false" contentBackgroundAlpha="0.0"
                    dataProvider="{GamesLijst}" itemRenderer="itemrenderers.GameRenderer"
                    rollOverColor="#0492B1"  dragMoveEnabled="true" dropEnabled="true" mouseDown="initiateDrag(event)">
                <s:layout >
                    <s:TileLayout horizontalGap="10" verticalGap="10" horizontalAlign="left" verticalAlign="top"/>
                </s:layout>
            </s:List>
        </s:NavigatorContent>

I want to drag the images out of the viewstack to an image, this is the code:

<s:HGroup includeIn="Home" x="225" width="310" height="90" gap="30" textAlign="left" verticalAlign="middle"> <s:Image width="100" height="100" source="menu/home.png" click.Home="home_clickHandler(event)"/> <s:Image width="100" height="100" source="menu/fav.png" click.Home="favorites_clickHandler(event)" dragEnter="dragEnterHandler(event)" dragDrop="dragDropHandler(event)"/> <s:Image width="100" height="100" source="menu/cart.png" click.Home="cart_clickHandler(event)"/> </s:HGroup>
0

There are 0 answers