Actionscript 3 flex spark列表在spark画布组件上拖放项目

Actionscript 3 flex spark列表在spark画布组件上拖放项目,actionscript-3,apache-flex,canvas,drag-and-drop,ria,Actionscript 3,Apache Flex,Canvas,Drag And Drop,Ria,我有一个spark列表,显示代表产品的图像列表。我正在尝试实现一个拖放功能,允许用户将他想要购买的产品从列表拖到画布区域,在那里他可以在购买之前看到他选择的产品。我正在使用下面的代码,但我无法找出它的错误,似乎我无法使用列表项作为绘图师,请任何人帮助: onMouseDown的私有函数(事件:MouseEvent):void { var list:List = List(event.currentTarget); var dragI

我有一个spark列表,显示代表产品的图像列表。我正在尝试实现一个拖放功能,允许用户将他想要购买的产品从列表拖到画布区域,在那里他可以在购买之前看到他选择的产品。我正在使用下面的代码,但我无法找出它的错误,似乎我无法使用列表项作为绘图师,请任何人帮助:

onMouseDown的私有函数(事件:MouseEvent):void {

                var list:List = List(event.currentTarget);
                var dragInitiator:Image = Image (list.selectedItem);
                var source : DragSource = new DragSource();
                source.addData(dragInitiator, "img");
                DragManager.doDrag(dragInitiator, source, event);

        }



        protected function canvas1_dragEnterHandler(event:DragEvent):void
        {

                DragManager.acceptDragDrop(Canvas(event.currentTarget));


        }

        protected function canvas1_dragDropHandler(event:DragEvent):void
        {
            Image(event.dragInitiator).x = 
                Canvas(event.currentTarget).mouseX;
            Image(event.dragInitiator).y = 
                Canvas(event.currentTarget).mouseY;  }


我认为您需要添加拖动启动器,它应该是您正在拖动的项目呈现器,而不是整个列表控件。
不是
列表。选择editem
这个简单的对象不像
UIComponent或VisualElement
你必须指向一些ui组件,比如
group

你能举个例子吗?因为我不知道如何将ui组件传递给绘图初始化器,问题是我的列表包含了imagee的名称,并且它加载了s运行时so列表中的图像。selecteditem返回一个srting
    <fx:Model id="categoriesModel" source="Data/Categories.xml"/>
    <s:ArrayList id="CategoriesCollection" source="{categoriesModel.Category}"/>

    <fx:Model id="productsModel" source="Data/Products.xml"/>
    <s:ArrayList id="ProductsCollection" source="{productsModel.Product}" />


</fx:Declarations>

<s:VGroup gap="5"  horizontalAlign="center">

    <s:HGroup gap="5">

        <Components:PROExpressLogo/>
        <s:List id="categoryList"   scroller="{null}"  visible="true"
                itemRenderer="Renderers.categoryItemRenderer" width="700"  borderAlpha="0" 
                change="categoryList_changeHandler(event)">
            <s:layout>
                <s:HorizontalLayout/>
            </s:layout>
        </s:List>   

    </s:HGroup>

    <s:List id="productList"   scroller="{null}" contentBackgroundAlpha="0.4" contentBackgroundColor="0xabcdef"
            itemRenderer="Renderers.productItemRenderer" width="880"  borderAlpha="0" visible="true" horizontalCenter="0" 
             dragEnabled="false" mouseDown="onMouseDown(event)"  
            >   
        <s:layout>
            <s:HorizontalLayout/>
        </s:layout>
    </s:List>

    <s:HGroup gap="20">
        <s:Group>
                <s:Image id="planImage" width="500" height="300" horizontalCenter="0"  
                         toolTip="Drag your items on your Plan and drop them were you plan to install them" 
                         />

                <mx:Canvas width="500" height="300" backgroundAlpha="0.1"
                           backgroundColor="#abcdef" borderColor="#abcdef" borderStyle="inset"
                           contentBackgroundColor="#abcdef" cornerRadius="10"
                           dragDrop="canvas1_dragDropHandler(event)"
                           dragEnter="canvas1_dragEnterHandler(event)" dropShadowVisible="true"
                           horizontalCenter="0"/>
        </s:Group>
                <s:List id="cart" width="200" height="300"/>
    </s:HGroup>