flex移动图片

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" >
<mx:Script>
    <![CDATA[
        import mx.events.MoveEvent;
        private var oldX:Number,oldY:Number;
        private function onMouseMove(event:MouseEvent):void{
            lbl.text = "Local (x,y):" + event.localX.toString() + ","+event.localX.toString();
            lbl2.text = "Stage (x,y):" + event.stageX.toString() + ","+event.stageY.toString();
            if(event.buttonDown){
                var x:Number = event.stageX - oldX;
                var y:Number = event.stageY - oldY;
                oldX = event.stageX;
                oldY = event.stageY;               
                img.move(img.x + x,img.y + y);       
            }
        }
       
        private function onMouseDown(event:MouseEvent):void{
            oldX = event.stageX;
            oldY = event.stageY;
        }
    ]]>
</mx:Script>
    <mx:Label x="10" y="10" text="" id="lbl"/>
    <mx:Label x="10" y="27" text="" id="lbl2"/>
    <mx:Panel x="88.5" y="75" width="90%" height="80%" layout="absolute"
    horizontalScrollPolicy="off" verticalScrollPolicy="off">
     <mx:Image id="img" x="10" y="40" source="1.png"
     mouseMove="onMouseMove(event)"
     mouseDown="onMouseDown(event)" width="184" height="181"/>
    </mx:Panel>
</mx:Application>

    A+
发布日期:2009年12月13日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: