6 Replies Latest reply on May 3, 2009 2:12 AM by IlyaG

    How can I put move requests in stuck and continue working?

    IlyaG Level 1

      I have a map and a unit moving on this map, I wont to give him 2 moving orders and continue for my another staff.

       

      this is part of my program so I try to explain to you the parameters of this function in the way I choose to represent it:

       

      destination:String is a string looking like this: "x,y" where x and y are the coronations.

       

      getLocNum(location:String, isX:boolean) returns the x value if isX set to true or the y value if its false.

       

      _units is an Array with images and you can ignore from unitID for now.

       

      _location:String is also a string form "x,y" family, that show the correct unit location.

       

      I hope this were clear enough for you to try and help me out with this.

       

      Here we go:

       

      public function testMoveUnit(destination:String,unitID:int=0):void

      {

      var myMove:Move=new Move();

      myMove.target=_units[unitID];

      myMove.xTo=getLocNum(destination,true)*30+38;

      myMove.duration=Math.abs(getLocNum(destination,true)-getLocNum(_location,true))*1000;

      myMove.play();

      myMove.yTo=getLocNum(destination,false)*30-28;

      myMove.duration=Math.abs(getLocNum(destination,false)-getLocNum(_location,false))*1000;

      myMove.play();

      _location=destination;

      }

       

      Right now the unit only moves for his x direction and if I remove the first myMove.play() request so its going for the destination, so the only problem is when I am adding my first move().

       

      And for another question may be more complicated then that is how can I know if my unit is in a middle of his move and I don't wont to interrupt him right now, I mean at the future when the function be called again.