Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 将拖放添加到弹出窗口中的文本区域_Actionscript 3_Apache Flex_Flash Builder4.5 - Fatal编程技术网

Actionscript 3 将拖放添加到弹出窗口中的文本区域

Actionscript 3 将拖放添加到弹出窗口中的文本区域,actionscript-3,apache-flex,flash-builder4.5,Actionscript 3,Apache Flex,Flash Builder4.5,我创建了一个ResizeableTitleWindow类,它扩展了Titlewindow以使其可调整大小。在RTW内部,我添加了一个文本区域,并将RTW显示为弹出窗口。如何将拖放添加到文本区域 public function createPopUpEdit():void { var rtw:ResizableTitleWindow = new ResizableTitleWindow(); var st:TextArea = new TextArea(); rtw.addElement(st);

我创建了一个ResizeableTitleWindow类,它扩展了Titlewindow以使其可调整大小。在RTW内部,我添加了一个文本区域,并将RTW显示为弹出窗口。如何将拖放添加到文本区域

public function createPopUpEdit():void {
var rtw:ResizableTitleWindow = new ResizableTitleWindow();
var st:TextArea = new TextArea();
rtw.addElement(st);
PopUpManager.addPopUp(rtw, this, false);
PopUpManager.centerPopUp(rtw);
通常通过在.mxml文件中设置属性来实现:

<s:TextArea id="st"
            dropEnabled="true"
            dragOver="onlyAllowCopyDragOverHandler(event)"
            dragDrop="myComponent_dragDropHandler(event)"
... 
我想在createPopUpEdit函数中执行以下操作:

st.dropEnabled="true";
st.dragOver="onlyAllowCopyDragOverHandler(event)";
etc.

编写以下代码。希望它能帮助你

            private var st:TextArea;
            private var rtw:TitleWindow;

            protected function init(event:FlexEvent):void
            {
                    rtw = new TitleWindow();
                    st = new TextArea();
                    st.width = 50;
                    st.height = 50;
                    st.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
                    st.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
                    rtw.width = 500;
                    rtw.height = 500;
                    rtw.addElement(st);
                    PopUpManager.addPopUp(rtw, this, false);
                    PopUpManager.centerPopUp(rtw);

            }

            private function onMouseDown(e:MouseEvent):void
            {
                st.startDrag(true,new Rectangle(0,0,rtw.width,rtw.height));
            }

            private function onMouseUp(e:MouseEvent):void
            {
                st.stopDrag();
            }
上面的代码将在popupView中拖放textarea

编辑:

要添加事件动态,您可以执行以下操作:

st.addEventListener(DragEvent.DRAG_OVER,onlyAllowCopyDragOverHandler);
st.addEventListener(DragEvent.DRAG_DROP,myComponent_dragDropHandler);
st.addEventListener(DragEvent.DRAG_OVER,onlyAllowCopyDragOverHandler);
st.addEventListener(DragEvent.DRAG_DROP,myComponent_dragDropHandler);