Leaves
中央部の見栄えが悪い
package {
import flash.display.Sprite;
import flash.events.Event;
import net.hires.debug.Stats;
[SWF(frameRate="30")]
public class FlashTest extends Sprite {
private var leaves:Vector.<Leaf>;
public function FlashTest() {
leaves=new Vector.<Leaf>();
for(var i:int=0;i<120;i++){
var leaf:Leaf=new Leaf();
leaf.x=465/2;
leaf.y=i*4-10;
leaf.rotationX=i*2;
leaf.rotation=Math.random()*360;
leaves.push(leaf);
addChild(leaf);
}
addEventListener(Event.ENTER_FRAME,onEnterFrame);
addChild(new Stats());
}
private function onEnterFrame(e:Event):void{
var l:int=leaves.length;
for(var i:int=0;i<l;i++){
leaves[i].rotation+=Math.random()*4-2;
}
}
}
}
import flash.display.Sprite;
import flash.display.Graphics;
class Leaf extends Sprite{
private static const colors:Array=[0x008000,0x00c000,0x00c000,0x00ff00,0xc0c000,0xe0e000,0xc00000,0x800000];
public function Leaf(){
var color:uint=2*(Math.random()*4>>0);
var g:Graphics=graphics;
g.lineStyle(1,0x000000,0.5);
g.beginFill(Leaf.colors[color]);
g.moveTo(0,0);
g.lineTo(2,2);
g.lineTo(50,0);
g.curveTo(100,-50,160,50);
g.curveTo(60,60,48,3);
g.lineTo(0,5);
g.endFill();
g.lineStyle(1,Leaf.colors[color+1]);
g.moveTo(0,4);
g.curveTo(80,-9,160,50);
}
}