Flex 4.6一切都可以拖动

时间:2012-11-27 21:48:27

标签: flex adobe flash-builder rich-media

我只是让我的itemrenderer(在视图堆中)可拖动,但现在我有以下问题,即我可以在视图堆栈中拖动所有内容。我只想拖动整个itemrenderer或它的一部分(封面)。此时我还可以拖动整个navigatorcontent和滚动条(!)。有人有解决我的问题的方法吗?提前thx!

(故障的例子及其必须的方式 - > 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>

我想将图像从视图堆栈拖到图像中,这是代码:

<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 个答案:

没有答案