forked from: Halloween 2010
Halloween 2010
...
@author
/**
* Copyright uwi ( http://wonderfl.net/user/uwi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/qECq
*/
// forked from okoi's Halloween 2010
//
// Halloween 2010
//
//
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.display.*;
import flash.geom.*;
[SWF(width = "465", height = "465")]
/**
* ...
* @author
*/
public class Main extends Sprite
{
private var pumpkin:Pumpkin;
private var step:int;
private var film:Shape;
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
graphics.beginFill(0);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
graphics.endFill();
pumpkin = new Pumpkin();
pumpkin.x = stage.stageWidth / 2;
pumpkin.y = stage.stageHeight / 2;
addChild( pumpkin );
step = 0;
addEventListener(Event.ENTER_FRAME, Update);
film = new Shape();
film.x = 465 / 2;
film.y = 465 / 2;
addChild(film);
}
private function Update(e:Event) : void
{
pumpkin.y = stage.stageHeight / 2 + Math.sin( step*2 % 360 * Math.PI / 180 ) * 20;
if(step % 3 == 0){
var gg : Graphics = film.graphics;
gg.clear();
var mat : Matrix = new Matrix();
mat.createBox(0.22, 0.22);
gg.beginGradientFill("radial", [0, 0], [0, 1], [0, 240 + Math.random() * 10], mat);
gg.drawRect(-465/2, -465/2, 465, 465);
gg.endFill();
}
step++;
}
}
}
import flash.display.GradientType;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.display.BlendMode;
import flash.filters.BlurFilter;
class Pumpkin extends Sprite
{
private var body:Sprite;
private var face:Sprite;
private var candle:Sprite;
private var step:int;
public function Pumpkin() {
var g:Graphics;
var color:uint = 0xFFBD38;
// Body
body = new Sprite();
drawBody( body.graphics );
drawFace( body.graphics );
// face
face = new Sprite();
drawFace( face.graphics, false );
//-------------
// Candle
candle = new Sprite();
var m:Shape = new Shape();
drawBody( m.graphics );
candle.mask = m;
candle.addChild( m );
addChild( candle );
body.blendMode = BlendMode.LAYER;
addChild( body );
face.blendMode = BlendMode.ERASE;
body.addChild( face );
step = 0;
addEventListener(Event.ENTER_FRAME, Update);
}
private function drawBody(g:Graphics):void
{
var color:uint = 0xFFBD38;
g.lineStyle( 10, 0xD68D00 );
g.beginFill(color);
g.drawEllipse( -150, -70, 100, 200); // 最後列
g.endFill();
g.beginFill(color);
g.drawEllipse( 50, -70, 100, 200);
g.endFill();
g.beginFill(color);
g.drawEllipse( -100, -60, 100, 200);
g.endFill();
g.beginFill(color);
g.drawEllipse( 0, -60, 100, 200);
g.endFill();
g.beginFill(color);
g.drawEllipse( -50, -50, 100, 200); // 中央
g.endFill();
}
private function drawFace(g:Graphics, line:Boolean = true ):void
{
// eye
if( line ) g.lineStyle(5, 0xD68D00);
g.beginFill(0);
g.moveTo( -70, 0 );
g.lineTo( -30, 40 );
g.lineTo( -110, 40 );
g.endFill();
if( line ) g.lineStyle(5, 0xD68D00);
g.beginFill(0);
g.moveTo( 70, 0 );
g.lineTo( 30, 40 );
g.lineTo( 110, 40 );
g.endFill();
// mouth
if( line ) g.lineStyle(5, 0xD68D00);
g.beginFill(0);
g.moveTo( -110, 50 );
g.curveTo( 0, 100, 110, 50 );
g.curveTo( 0, 200, -110, 50 );
g.endFill();
}
private function Update(e:Event):void
{
var g:Graphics = candle.graphics;
var size:Number = 70;
candle.filters = [new BlurFilter(15,15,Math.random()*10+5)];
g.clear();
g.beginFill(0xFFEB44);
g.drawCircle(0, 50, size);
g.endFill();
step++;
}
}