In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

飛行機

Get Adobe Flash player
by keno42 11 Mar 2009
package {
    import flash.display.Sprite;
    import flash.events.*;
    public class FlashTest extends Sprite {
        private var _num:int = 200;
        private var _airplanes:Vector.<Airplane> = new Vector.<Airplane>(_num);
        public function FlashTest() {
            // write as3 code here..
            var rotsp:Sprite = new Sprite();
            var sprite:Sprite = new Sprite();
            var shadow:Sprite = new Sprite();
            for( var i:int = 0; i < _num; i++ ){
                var airplane:Airplane = new Airplane();
                rotsp.addChild(airplane);
                _airplanes[i] = airplane;
            }
            this.graphics.beginFill(0x8888CC);
            this.graphics.drawRect(-232, -232, 465, 465);
            shadow.graphics.beginFill(0x88CC88);
            shadow.graphics.drawRect(-1000,-1000,2000,2000);
            this.addChild(shadow);
            this.addChild(sprite);
            sprite.rotationX = -80;
            rotsp.rotationZ = -90;
            sprite.addChild( rotsp );
            shadow.rotationY = -80;
            shadow.rotationZ = -90;
            sprite.z = -300;
            shadow.z = 200;
            this.x = 232;
            this.y = 232;
            this.addEventListener(Event.ENTER_FRAME,onEnter);
        }
        private function onEnter(event:Event):void{
            for( var i:int = 0; i < _num; i++ ){
                _airplanes[i].update();
            }
        }
    }
}
import flash.display.Sprite;
import flash.filters.*;
class Airplane extends Sprite{
    public var vx:Number;
    public function Airplane(){
        x = Math.random() * 1000 - 100;
        y = Math.random() * 2000 - 1000;
        vx = Math.random() * 5 + 1;
        var color:int = Math.random() * 0xFFFFFF | 0x444444;
        var vTail:Sprite = new Sprite();
        vTail.graphics.beginFill(color);
        vTail.graphics.lineStyle(1);
        vTail.graphics.moveTo(10,0);
        vTail.graphics.lineTo(0,5);
        vTail.graphics.lineTo(0,0);
        var wing:Sprite = new Sprite();
        wing.graphics.beginFill(color);
        wing.graphics.lineStyle(1);
        wing.graphics.moveTo(13,0);
        wing.graphics.lineTo(0,5);
        wing.graphics.lineTo(0,-5);
        wing.graphics.lineTo(13,0);
        var shadow:Sprite = new Sprite();
        shadow.graphics.beginFill(0x0);
        shadow.graphics.moveTo(13,0);
        shadow.graphics.lineTo(0,5);
        shadow.graphics.lineTo(0,-5);
        shadow.graphics.lineTo(13,0);
        this.addChild(vTail);
        this.addChild(wing);
        this.addChild(shadow);
        shadow.z = 50;
        vTail.rotationX = 90;
   }
    public function update():void{
        x+=vx;
        if( x > 1000 ){
            y = Math.random() * 2000 - 1000;
            x = -100;
            var p:Sprite = this.parent as Sprite;
            p.removeChild(this);
            p.addChild(this);
        }
        if( x > 500 ){
            this.filters = [new BlurFilter()];
        } else {
            this.filters = [];
        }
    }
}