Skip navigation
LukeElChul
Currently Being Moderated

Array and moving a object???

Apr 25, 2012 10:07 AM

Tags: #help #flash #frame #swf #dynamic #button #buttons #as2 #play #actionscript #movieclip #actionscript_2 #game #movie #clip #2.0 #movie_clip #dinamyc

I want so when i make worker it moves to a object called Garrison.

 

 

 

import mx.transitions.Tween;

import mx.transitions.easing.*;

 

 

workers = new Array();

tag=0;

 

 

function CreateWorker(){

          worker = _root.attachMovie("worker","worker" +tag, tag,{_x:55,_y:55})

worker.gotoFunction = GarrisonPoint();

workers.push(worker);

                    tag++;

}

function GarrisonPoint(){

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

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

}

 

Help?

 
Replies
  • Currently Being Moderated
    Apr 25, 2012 11:31 AM   in reply to LukeElChul

    It is not clear what you want the array to do for you, but here is one way to make the new worker move to the Garrison object.

     

    import mx.transitions.Tween;
    import mx.transitions.easing.*;

     

    var workers = new Array();
    var tag = 3;

     

    function CreateWorker(){
        worker = _root.attachMovie("worker","worker" +tag, tag,{_x:55,_y:55})
        garrisonPoint(worker);
        workers.push(worker);
        tag++;
    }

    function garrisonPoint(wkr){
        var t1:Tween = new Tween(wkr, "_x", None.easeNone, this._x, _root.Garrison._x, 10, true);
        var t2:Tween = new Tween(wkr, "_y", None.easeNone, this._y, _root.Garrison._y, 10, true);
    }

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 26, 2012 7:26 AM   in reply to LukeElChul

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points