/** Flower 4 2007 by Duncan Holby. www.glyfconstruct.com Protected under the Creative Commons Licence. For non-commerical use only. Feel free to use but please credit. Credit to Jared Tarbel for use of the naturally occurring angle of 137.5 degrees: www.levitated.net For use with Garden.as, Pedal.as. Takes 1 argument for radius, which automatically adjusts the number of pedals generated. **/ package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.utils.*; public class Flower4 extends Sprite { private var pedalLimit:uint; private var radius:Number; private var c:uint = 0; private var red:uint; private var green:uint; private var blue:uint; private var pedalHue:uint; private var pedals:Array = new Array; private var pedalAngle:Number = 137.5; private var pedalInterval:uint = 30; public function Flower4(radius:Number = 30) { this.radius = radius; this.pedalLimit = 1+radius*.5; init(); }; private function init() { var intervalId:uint = setInterval(pedalGenerator, pedalInterval); }; private function pedalGenerator ():void { blue = Math.floor(Math.random()*180); green = Math.floor(Math.random()*200); red = Math.floor(Math.random()*100)+200; pedalHue = red << 16 | green << 8 | blue; if(pedals[c] != null) { removeChild(pedals[c]); delete(pedals[c]); }; pedals[c] = new Pedal(-5, 0, pedalHue, 10, 2); pedals[c].x = 0; pedals[c].y = 0; pedals[c].rotation = c*pedalAngle; addChild(pedals[c]); c++; if (c == pedalLimit) { c = 0; }; var correctedMouse:Number = mouseX/10; if (mouseX <3 && mouseX>-3) { correctedMouse = 3/10; } for (var i:uint=0; i