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 aaaaaz025 29 Jan 2011
/**
 * Copyright aaaaaz025 ( http://wonderfl.net/user/aaaaaz025 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4Ds9
 */

package
{
    import flash.display.Sprite;
    import flash.events.Event;
 
    public class Main extends Sprite
    {
        private var bullets:Array;
        private var frame:int = 0;
 
        public function Main()
        {
            graphics.beginFill(0x000000); //0xカラーコード(背景色)
            graphics.drawRect(0, 0, 465, 465); //背景の幅
            graphics.endFill();
            
            bullets = new Array();
 
            addEventListener(Event.ENTER_FRAME, onEnterFrame);
        }
 
        private function onEnterFrame(event:Event):void
        {
            if (frame++ % 1 == 0)
            {
                var radian:Number = Math.random() * 360 * Math.PI / 180;
                var bullet:Bullet = new Bullet(0x00FFFF, 15, 232, 80, Math.cos(radian), Math.sin(radian), Math.random() * 5 + 7);
                addChild(bullet);
                bullets.push(bullet);
                
                var radian:Number = Math.random() * 360 * Math.PI / 180;
                var bullet:Bullet = new Bullet(0xff3399, 25, 232, 80, Math.cos(radian), Math.sin(radian), Math.random() * 5 + 1);
                addChild(bullet);
                bullets.push(bullet);

                
                var radian:Number = Math.random() * 360 * Math.PI / 180;
                var bullet:Bullet = new Bullet(0x000099, 7, 232, 80, Math.cos(radian), Math.sin(radian), Math.random() * 5 + 2);
                addChild(bullet);
                bullets.push(bullet);
                
                var radian:Number = Math.random() * 360 * Math.PI / 180;
                var bullet:Bullet = new Bullet(0xFFFF00, 15, 232, 80, Math.cos(radian), Math.sin(radian), Math.random() * 5 + 5);
                addChild(bullet);
                bullets.push(bullet);
                
                var radian:Number = Math.random() * 360 * Math.PI / 180;
                var bullet:Bullet = new Bullet(0xF0F0F0, 7, 232, 80, Math.cos(radian), Math.sin(radian), Math.random() * 5 + 2);
                addChild(bullet);
                bullets.push(bullet);

            }

 
            for (var i:int = 0; i < bullets.length; i++)
            {
                bullets[i].move();
                if (bullets[i].check())
                {
                    removeChild(bullets[i]);
                    bullets.splice(i--, 1);
                }
            }
        }
    }
}
 
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
 
class Bullet extends Sprite
{
    public var px:Number;
    public var py:Number;
    public var vx:Number;
    public var vy:Number;
    public var speed:Number;
 
    public function Bullet(color:int, radius:int, x:int, y:int, vx:Number, vy:Number, speed:Number)
    {
        graphics.beginFill(color);
        graphics.drawCircle(0, 0, radius);
        graphics.endFill();
 
        this.filters = [new DropShadowFilter(2, 0, 0x0)];
 
        this.x = this.px = x;
        this.y = this.py = y;
        this.vx = vx;
        this.vy = vy;
        this.speed = speed;
    }
 
    public function move():void
    {    
        this.px += vx * speed;
        this.py += vy * speed;
 
        this.x = px;
        this.y = py;
    }
 
    public function check():Boolean
    {
        if (x < -50 || stage.stageWidth  + 50 < x ||
            y < -50 || stage.stageHeight + 50 < y)
        {
            return true;
        }
 
        return false;
    }
}