sdk:flex
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
backgroundGradientAlphas="0.5" backgroundGradientColors="black"
color="#FFFFFF" backgroundColor="#FFFFFF">
<mx:Script>
<![CDATA[
import mx.controls.SWFLoader;
import mx.core.UIComponent;
import mx.events.ListEvent;
private var oldx:Number;
private var oldy:Number;
private function mouseMove(event:MouseEvent):void{
if(event.buttonDown){
var dragItem:UIComponent = event.currentTarget as UIComponent;
var x:Number = event.stageX - oldx;//移动的x坐标
var y:Number = event.stageY - oldy;//移动的y坐标
oldx = event.stageX; //把当时的坐标 给oldx oldy
oldy = event.stageY;
dragItem.move(dragItem.x+x,dragItem.y+y); //move 是移动函数
}
}
private function mouseDown(event:MouseEvent):void{
oldx = event.stageX;
oldy = event.stageY;
}
private function mouseUp(event:MouseEvent):void{
}
]]>
</mx:Script>
<mx:Canvas x="100" y="100" width="100%" height="100%">
<mx:Image x="10" y="10" width="400" height="300"
mouseMove="mouseMove(event)"
mouseDown="mouseDown(event)"
mouseUp="mouseUp(event)" source="@Embed(source='assets/img1.jpg')"/>
<mx:SWFLoader x="550" y="10" width="400" height="300"
mouseMove="mouseMove(event)"
mouseDown="mouseDown(event)"
mouseUp="mouseUp(event)" source="assets/chinaMap.swf"/>
</mx:Canvas>
</mx:Application>