如何在Vbox中拖放画布重新排序?

时间:2009-03-07 17:25:44

标签: flex actionscript-3

我正在快速使用Flex,我正在寻找在vbox容器中实现拖放重新排序的任何示例。基本上我有一个Vbox,其中包含一些全宽和35px高的画布。我希望能够拖放它们以在vbox中重新排序。

非常感谢任何帮助 - 谢谢,

B'/ P>

2 个答案:

答案 0 :(得分:0)

如果我是你,我首先检查在线提供的Flex文档。有this例子。您必须为列表控件的itemeditor自定义它。还有另外一个example你应该看看。如果您有任何问题,请告诉我们。

答案 1 :(得分:0)

您是否尝试过使用mx:List - 拖放支持已经内置并且非常易于使用 - 我使用您提到的尺寸为您整理了一个样本:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.DragEvent;
            import mx.collections.ArrayCollection;

            [Bindable]
            private var _source:ArrayCollection = new ArrayCollection();

            private function init():void{

                var n:int = 10;
                for(var i:int = 0; i < n; i++){ _source.addItem({value:Math.random()}); }

            }

            private function handleReorder(event:DragEvent):void{

                Alert.show("A change was made!");

            }

        ]]>
    </mx:Script>

    <mx:List dataProvider="{_source}" width="250" height="500" dragMoveEnabled="true" 
             dragEnabled="true" dropEnabled="true" dragDrop="handleReorder(event)">
        <mx:itemRenderer>
            <mx:Component>
                <mx:Canvas width="100%" height="35">
                    <mx:Text text="{data.value}" width="100%" height="100%" selectable="false" />
                </mx:Canvas>
            </mx:Component>
        </mx:itemRenderer>
    </mx:List>

</mx:Application>

当然有更多信息:http://livedocs.adobe.com/flex/3/langref/mx/controls/List.html

祝你好运!