BodyInit Actionscript

Table of contents | Previous document | Download BodyInit.as | SWF!T Homepage

RCSfile: BodyInit.as,v  Revision: 1.1  Date: 2003/04/22 14:28:12  

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.


Init script for the body ...
author      Olaf Havnes
version     Revision: 1.1  Date: 2003/04/22 14:28:12  
since       SWFIT1.0


The rotation of the body is constant

ROTATION_SPEED = 4;

Number of pegs - and legs for the clip above us.

NUM_PEGS = 3;

Measure and duplicate the pegs

peg_center_radius = peg_0._x;
peg_radius = peg_0._width / 2;

The angle and half angle between two pegs.

peg_angle_step = /:NUM_DEG / NUM_PEGS;
peg_angle_step_half = peg_angle_step / 2;

Duplicate the pegs.

i = 0;
while (i < NUM_PEGS)
{
   peg_name = "peg_" add i;
   if (i > 0) duplicateMovieClip ("peg_0", peg_name, i);
   peg_angle = i * peg_angle_step + peg_angle_step_half;

   setProperty (peg_name, _x, eval ("/:COS_" add int(peg_angle)) * peg_center_radius);
   setProperty (peg_name, _y, eval ("/:SIN_" add int(peg_angle)) * peg_center_radius);
   setProperty (peg_name, _rotation, - peg_angle);
   i++;
}