RobbleWobbleLoop Actionscript
Table of contents | Previous document | Download RobbleWobbleLoop.as | SWF!T Homepage RCSfile: RobbleWobbleLoop.as,v Revision: 1.2 Date: 2003/02/05 02:30:16
Copyright 2003 Orgdot AS. All Rights Reserved. http://dev.swfit.com
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
RobbleWobbleLoop.as is a little loop that will wobble a rotation around a specific angle. This angle can easily be set by a script action in f.i a button. The main thing to notice is that we always set a positive angle, and that we always will choose the shortest distance between two angles. So - the shortest distance from 2 degrees to 358 degrees is -4 degrees - to -2 degrees.
The angle should be stored in _level0 - and the name should be the name of the roto-clip + "_angle";
author Olaf Havnes
version Revision: 1.2 Date: 2003/02/05 02:30:16
since SWFIT1.0
We read our destination angle from _level0:
to_angle = eval ("/:" add _name add "_angle");
Place the destination angle value inside the first 360 degrees.
while (to_angle < 0) to_angle += 360;
while (to_angle >= 360) to_angle -= 360;
Place the stored angle value inside the first 360 degrees.
while (from_angle < 0) from_angle += 360;
while (from_angle >= 360) from_angle -= 360;
Find the SHORTEST distance from the stored value to the destination value.
dist_angle = to_angle - from_angle;
if (dist_angle > 180) dist_angle -= 360;
if (dist_angle < -180) dist_angle += 360;
Compute the speed based on distance we have to travel.
speed_angle += ac * dist_angle - fr * speed_angle;
Set the new angle.
from_angle += speed_angle;
_rotation = from_angle;
We need to set the scale to 100%, since flash for some reason nudges the scale
slightly for each rotate command.
_xscale = 100;
_yscale = 100;
|
|