blob: e8681b2049c3e3209171201782f624c26023a073 [file] [log] [blame]
<?xml version="1.0" encoding="iso-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="600" height="600">
<mx:Script>
<![CDATA[
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.events.DragEvent;
import flash.events.MouseEvent;
private var xOff:Number;
private var yOff:Number;
private function dragMe(event:MouseEvent, img1:Object, format:String): void
{
var ds:DragSource = new DragSource()
ds.addData(img1, format);
var di:MXMLcomp = new MXMLcomp();
DragManager.doDrag(MXMLcomp(event.currentTarget), ds, event, di);
}
private function doDragEnter(event:DragEvent): void
{
DragManager.acceptDragDrop(Canvas(event.target));
}
private function doDragDrop(event:MouseEvent,target1:Object, format:String): void
{
comp.x = target1.mouseX - xOff
comp.y = target1.mouseY - yOff
}
private function myoffset(img:Object): void
{
xOff = img.mouseX;
yOff = img.mouseY;
}
]]>
</mx:Script>
<mx:HBox backgroundColor="#CCCCFF" horizontalAlign="center" width="100%">
<mx:Label fontSize="15" text="Drag and Drop MXML Component" />
</mx:HBox>
<mx:Text width="100%" text="Drag question mark around stage. Verify it moves around correctly, following the mouse, and drag image appears correctly" />
<mx:Canvas id="v1"
width="500"
height="500"
dragEnter="doDragEnter(event)"
dragDrop ="doDragDrop(event,v1, 'img')"
borderStyle="solid"
backgroundColor="#DDDDDD" >
<MXMLcomp id="comp" xmlns="*" mouseDown="dragMe(event, 'Image', 'img');myoffset(comp)"/>
</mx:Canvas>
</mx:Application>