2 Replies Latest reply on Nov 26, 2007 12:37 PM by ChristopherCesarz

    How to make it move correctly?


      I made a simple Flex application. There is a helicopter which will move to points that user clicks in the canvas. For example, it is at A point. When I click at B point, the helicopter will move to B. Then it will move to C when I click at C.

      However, the problem arises when I click at B, C, D continuously. It moved from A to B. However, I don't think it moved from B to C. Maybe it moved from B' to C.

      Please tell me how to make it move correctly.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      import flash.events.Event;
      import mx.controls.Alert;

      [Embed(source="library.swf", symbol="Helicopter")]
      public var MayBay:Class;

      public var xF:Number;
      public var xT:Number;
      public var yF:Number;
      public var yT:Number;

      public function onCanvasClick(event:Event):void
      var x:Number= myCanvas.mouseX;
      var y:Number= myCanvas.mouseY;

      var oX:Number=h1.x;
      var oY:Number=h1.y;


      // Alert.show("x="+x+" y="+y+" xOld="+oX+" yOld="+oY);


      <mx:Move id="MoveEffect" target="{h1}" xFrom="{xF}" yFrom="{yF}" xTo="{xT}" yTo="{yT}" duration="2000" >

      <mx:State id="NewState">

      <mx:Panel width="70%" height="50%" title="Vi du">
      <mx:Canvas click="onCanvasClick(event)" id="myCanvas" width="100%" height="100%" color="White">
      <mx:Image id="h1" source="{MayBay}" width="80" height="50">