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 gaziya 21 Nov 2011
/**
 * Copyright gaziya ( http://wonderfl.net/user/gaziya )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/5XcA
 */

package {
    import flash.geom.Point;
    import flash.display.Shape;
    import flash.utils.setInterval
    import flash.events.Event;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {        
        public function FlashTest() {
            var i:int
            graphics.beginFill(0x101010)                
            graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight)
            
            var cores:Vector.<Shape> = new Vector.<Shape>
            var speeds:Vector.<Point> = new Vector.<Point>(3)
            for (i=0; i<3; i++){
                cores.push(addChild(new Shape) as Shape)
                with (cores[i]) {
                    graphics.beginFill(0xf08000)
                    graphics.drawCircle(0,0,5)
                    x = stage.stageWidth*Math.random()
                    y = stage.stageHeight*Math.random()
                }
            }
            x_speed()
            setInterval(x_speed,1500)
            function x_speed():void {
                for (i=0; i<speeds.length; i++) {
                    speeds[i] = new Point((Math.random()-0.5)*2, (Math.random()-0.5)*2)
                }
            }              
           
            var barrages:Vector.<Barrage> = new Vector.<Barrage>       
            fire()     
            setInterval(fire,250)
            function fire():void {
                for (i=0; i<cores.length; i++) {                             
                    barrages.push(addChild(new Barrage(cores[i].x,cores[i].y)) as Barrage) 
                }
            }

            addEventListener(Event.ENTER_FRAME, loop)
            function loop(e:Event):void {
                for (i=0; i<cores.length; i++) {
                    if (cores[i].x+speeds[i].x > 20 && cores[i].x+speeds[i].x < stage.stageWidth-20){
                        cores[i].x += speeds[i].x
                    }
                    if (cores[i].y+speeds[i].y > 20 && cores[i].y+speeds[i].y < stage.stageHeight-20){
                        cores[i].y += speeds[i].y
                    }
                }
                while (barrages[0].radius > 100){
                    removeChild(barrages[0])
                    barrages.shift()
                }
                for (i=0; i<barrages.length; i++){
                    barrages[i].draw()
                }
            }          
        }
    }
}

import flash.display.Sprite

class Barrage extends Sprite {
    public var radius:Number = 10
    
    public function Barrage(px:int, py:int) {
        x = px
        y = py       
    }
    
    public function draw():void {
        var split:int = 24
        var unit_theta:Number = 2*Math.PI/split
        graphics.clear()
        graphics.beginFill(0x80f0)
        for (var i:int=0; i<split; i++) {
            graphics.drawCircle(
                radius*Math.cos(i*unit_theta),
                radius*Math.sin(i*unit_theta),
                2)
        }
        radius += 1
    }
}