1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();" >
<mx:Panel x="47" y="78" width="200" height="200" backgroundColor="#FFFFFF" layout="absolute" id="pan1" >
<mx:TitleWindow x="10" y="10" label="Button" mouseMove="mouseOverHandler(event);" width="160"
backgroundColor="#F60B0B" height="77">
</mx:TitleWindow>
<mx:Button x="40" y="118" label="Button2"/>
</mx:Panel>
<mx:Panel x="460" y="78" width="200" height="200" backgroundColor="#FFFFFF"
dragDrop="dragDropHandler(event)" id="pan2" dragEnter="dragEnterHandler(event)">
</mx:Panel>
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.containers.TitleWindow;
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.events.DragEvent;
import mx.containers.Canvas;
public function init():void
{
DragManager.showFeedback(DragManager.COPY);
}
private function mouseOverHandler(event:MouseEvent):void
{
var dragInitiator:TitleWindow = event.currentTarget as TitleWindow;
var ds:DragSource= new DragSource();
ds.addData(dragInitiator, "can");
var imageProxy:TitleWindow = new TitleWindow();
DragManager.doDrag(dragInitiator, ds, event, imageProxy);
}
private function dragEnterHandler(event:DragEvent):void
{
if (event.dragSource.hasFormat("can"))
{
DragManager.acceptDragDrop(pan2);
}
}
private function dragDropHandler(event:DragEvent):void
{
var window:TitleWindow= event.dragInitiator as TitleWindow;
window.x = 10;
window.y = 10;
window.showCloseButton=true;
window.addEventListener(CloseEvent.CLOSE, fermer_h)
pan2.addChild(window);
trace(DragManager.getFeedback());
}
public function fermer_h(event:CloseEvent):void
{
pan2.removeChild(TitleWindow(event.currentTarget));
}
]]>
</mx:Script>
</mx:Application> |
Partager