- Home
- Tutorials
- Flash
- Intermediate
- Actionscript Powered Movement

Page 5 of 5
Jesse Stratford
Jesse lives and works in Melbourne Australia. He is the Cofounder of http://ActionScript.org. A Flash enthusiast, teacher, author, freelancer and speaker Jesse's main focus nowadays is managing http://ActionScript.org, but he enjoys participating actively in community and the wider Flash scene when he has time.
View all articles by Jesse StratfordWhat it does and how (line by line):
Frame 1:stop();
loops = 0;
_root.running = false;
- Stop all actions. Yup, he's still a lazy fatController.
- Variable loops equals 0. This sets the number of moves to do back to 20.
- Variable running is false, since this clip is stopped and thus is not telling our circle to do anything.
_root.running = true;
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;
- Variable running is now true because we are back to telling the circle to do stuff.
- Variable loops increments, since we're about to take one step.
- Sets the _x of our 'circle' to it's current _x plus one step's value.
- As above for _y.
Frame 3:
loops++;
_root.circle._x += _root.xdiv;
_root.circle._y += _root.ydiv;
if (loops < 20) {
gotoAndPlay(2);
} else {
gotoAndStop(1);
}
- Increment loops variable.
- Sets the _x of our 'circle' to it's current _x plus one step's value.
- As above for _y.
- If variable loops is less than 20, ("Are we there yet!?");
- Loops less than 20, we're not there yet, loop to frame 2 and play.
- Otherwise, loops must be greater than or equal to 20, so we're there!;
- Go back to frame 1 of the fatController.
So frames 2 and 3 loop between each other until we reach our chosen destination, at which point they jump back to frame 1 and the clip stops.
And if the user clicks while it's in motion? Well since running == true, it sets the number of moves back to 20, sets the xdiv and ydiv variables to their new values and off it goes again! Smart users could implement this technique in a Mouse Chaser with Delay sort of scenario. Just have a looping MC which continually gets the mouse _x and _y and sets them as the target for the clip... But that's for another tutorial. Cheers!
| Jesse Stratford is the Co-Master of ActionScript.org and a freelance Flash developer and teacher. He is based in Australia and enjoys all things Flash. NB: If you have comments or feedback please feel free to email me, but please do not email me Flash questions; the forums are provided for that purpose and you will get a faster answer by posting you question there. |
If you have found this tutorial helpful, I hope that you will take 30 seconds to visit The Hunger Site where, with just one click you can make a free donation of food to a starving person in a third-world country. We do not benefit financially from this action; it is purely an act of charity. |
| This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution. I've worked hard on this tutorial, please don't steal it. |
Spread The Word
Article Series
-
Actionscript Powered Movement


