blob: 7a74ab6aa8406f57e95ee8146b8887c898163c98 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:s="library://ns.adobe.com/flex/spark" width="800" height="700"
xmlns:comps="comps.*" useNativeDragManager="false">
<s:layout>
<s:VerticalLayout />
</s:layout>
<fx:Script>
<![CDATA[
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.events.DragEvent;
import flash.events.MouseEvent;
import comps.MXMLcomp;
public var xOff:*;
public var yOff:*;
public function dragMe(event:MouseEvent, img1:*, format:*) : void
{
var ds:DragSource = new DragSource()
ds.addData(img1, format);
var di:Image = new Image();
di.source = "../../../../Assets/Images/unknown.jpg";
di.width=78;
di.height=78;
mx.managers.DragManager.doDrag(Image(event.currentTarget), ds, event, di);
}
public function dragMe2(event:MouseEvent, img1:*, format:*) : void
{
var ds:DragSource = new DragSource()
ds.addData(img1, format);
var di:MXMLcomp = new MXMLcomp();
mx.managers.DragManager.doDrag(MXMLcomp(event.currentTarget), ds, event, di);
}
public function dragMe3(event:MouseEvent, img1:String, format:String): void
{
var ds:DragSource = new DragSource();
ds.addData(img1, format);
var di:Image = new Image();
di.source = "../../../../Assets/Images/unknown.jpg";
di.width=78;
di.height=78;
mx.managers.DragManager.doDrag(Image(event.currentTarget), ds, event, di, 100, 100);
}
public function dragMe4(event:MouseEvent, img1:String, format:String) : void
{
var ds:DragSource = new DragSource();
ds.addData(img1, format);
mx.managers.DragManager.doDrag(Image(event.currentTarget), ds, event);
}
public function doDragEnter(event:DragEvent) : void
{
mx.managers.DragManager.acceptDragDrop(Canvas(event.target));
}
public function doDragDrop(event:DragEvent,target1:*, format:*) : void
{
event.dragInitiator.x = target1.mouseX - xOff;
event.dragInitiator.y = target1.mouseY - yOff;
}
public function myoffset(img:*) : void
{
xOff = img.mouseX
yOff = img.mouseY
}
public function callDrag(event:MouseEvent): void
{
dragMe4(event, 'Image', 'img');
myoffset(myImage);
}
]]>
</fx:Script>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
mx|DragManager {
defaultDragImageSkin: Embed('../../../../Assets/Images/dropSkin.jpg');
}
</fx:Style>
<mx:Canvas id="v1"
width="500"
height="500"
dragEnter="doDragEnter(event)"
dragDrop ="doDragDrop(event,v1, 'img')"
borderStyle="solid"
backgroundColor="#DDDDDD"
>
<mx:Image id="myImage" source="@Embed('../../../../Assets/Images/unknown.jpg')" mouseDown="dragMe(event, 'Image', 'img');myoffset(myImage);"/>
<comps:MXMLcomp id="comp" x="0" y="250" mouseDown="dragMe2(event, 'Image', 'img');myoffset(comp)"/>
<mx:Image id="myImage2" source="@Embed('../../../../Assets/Images/unknown.jpg')" mouseDown="dragMe3(event, 'Image', 'img');myoffset(myImage2);"
x="250" y="200" />
</mx:Canvas>
</s:WindowedApplication>