3 Replies Latest reply on Oct 26, 2011 3:01 PM by Ned Murphy

    Moving in wrong direction????

    LukeElChul Level 1

      ok ive made this script what pushes this function into an array called unitArray.


      this goes on the first frame of unit.





      import mx.transitions.Tween;

      import mx.transitions.easing.*;


      this.onRelease = function(){

      this.onMouseUp = function(){


      var t1:Tween = new Tween(this, "_x", None.easeNone, this._x, _xmouse, 10, true);

      var t2:Tween = new Tween(this, "_y", None.easeNone, this._y, _ymouse, 10, true);


      dy = _root._ymouse-this._y;

      dx = _root._xmouse-this._x;


      radianrotation = Math.atan2(dy, dx);

      radianrotation = radianrotation*180/Math.PI;

      this._rotation = radianrotation;


      delete this.onMouseUp;





      this goes on the main timeline.


      unitArray = new Array();



      it all works but my problam is that when i click on the stage the unit should move where i clicked. but instead it moves in a random direction and i cant figure out why?????