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

Movimento Orgânico

Meu primeiro teste no WonderFL
Get Adobe Flash player
by gabriel.eu.br 21 Oct 2011
    Embed
/**
 * Copyright gabriel.eu.br ( http://wonderfl.net/user/gabriel.eu.br )
 * GNU General Public License, v3 ( http://www.gnu.org/licenses/quick-guide-gplv3.html )
 * Downloaded from: http://wonderfl.net/c/ofkR
 */

package {
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class FlashTest extends Sprite {
        private var insetos:Array = new Array();
        public function FlashTest() {
            for(var i:uint = 0; i < 100; i++) {
                insetos.push(new Inseto());
                insetos[i].x = Math.random() * stage.stageWidth;
                insetos[i].y = Math.random() * stage.stageHeight;
                stage.addChild(insetos[i]);
            }
            stage.addEventListener("enterFrame", atualizar);
        }
        public function atualizar(ev:Event = null):void {
            for(var i:uint = 0; i < 100; i++) insetos[i].atualizar()
        }
    }
}

import flash.display.Shape;
class Inseto extends Shape {
    private var dif:Number;
    private var vel:Number;
    private var ang:Number;
    public function Inseto(vel:Number = 2, dif:Number = .2) {
        this.vel = vel;
        this.dif = dif;
        ang = Math.PI / 2;
        this.graphics.beginFill(0xffffff * Math.random());
        this.graphics.moveTo(0, 0);
        this.graphics.lineTo(-10,5);
        this.graphics.lineTo(-10,-5);
        this.graphics.endFill();
    }
    public function atualizar():void {
        ang += (Math.random() - .5) * dif;
        this.rotation = ang / Math.PI * 180;
        this.x += Math.cos(ang) * vel;
        this.y += Math.sin(ang) * vel;
        if(this.x < 0) this.x = stage.stageWidth;
        if(this.x > stage.stageWidth) this.x = 0;
        if(this.y < 0) this.y = stage.stageHeight;
        if(this.y > stage.stageHeight) this.y = 0;
    }
}