[AIR] Drag Problem (parent & children can receive d&d and HTML Control)
hi,
i have problem regarding drag , drop in air. d&d involving parent & children can receive d&d event , children can contain html control. might want copy , paste code below better idea.
the objectives are:
1. if drag green object , drop in black area, should alert "parent drop"
2. if drag green object , drop in magenta (purple) color, should alert "child drop"
3. if drag green object , drop in white (html control) color, should alert "html drop"
the problems:
1. drag green object black area, magenta area, , again black area. drop it, alert not shown
2. drag green object white area (html control). drop it, alert not shown
many thanks.
the code:
<?xml version="1.0" encoding="utf-8"?> <mx:windowedapplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()"> <mx:vbox verticalgap="0" x="50" y="50" width="200" height="200" backgroundcolor="#000000" horizontalalign="center" dragenter="onparentdragenter(event)" dragdrop="onparentdrop(event)"> <mx:canvas id="canvas1" width="50" height="50" backgroundcolor="#00ff00" mousemove="onmousemove(event)"/> <mx:html id="html" width="50" height="50" dragenter="onhtmldragenter(event)" dragdrop="onhtmldrop(event)"/> <mx:canvas id="canvas2" width="60" height="50" backgroundcolor="#ff00ff" dragenter="onchilddragenter(event)" dragdrop="onchilddrop(event)"/> </mx:vbox> <mx:script> <![cdata[ import mx.controls.alert; import mx.events.dragevent; import mx.managers.dragmanager; import mx.core.dragsource; public function init():void { html.htmltext = '<div style="font-size:small">html control</div>'; } public function onmousemove(event:mouseevent):void { var draginitiator:canvas = event.currenttarget canvas; var ds:dragsource = new dragsource(); ds.adddata("item", "item"); dragmanager.dodrag(draginitiator, ds, event, draginitiator); } public function onchilddragenter(event:event):void { trace("onchilddragenter"); dragmanager.acceptdragdrop(event.currenttarget canvas); } public function onparentdragenter(event:event):void { trace("onparentdragenter"); dragmanager.acceptdragdrop(event.currenttarget vbox); } public function onchilddrop(event:dragevent):void { trace("onchilddrop"); alert.show("child drop"); } public function onparentdrop(event:dragevent):void { trace("onparentdrop"); alert.show("parent drop"); } public function onhtmldragenter(event:dragevent):void { dragmanager.acceptdragdrop(event.currenttarget html); } public function onhtmldrop(event:dragevent):void { alert.show("html drop"); } ]]> </mx:script> </mx:windowedapplication>
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment