flash on 2011-5-23

by yama3
♥0 | Line 117 | Modified 2011-05-23 12:08:45 | MIT License
play

ActionScript3 source code

/**
 * Copyright yama3 ( http://wonderfl.net/user/yama3 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/8PN9
 */

package {
    import flash.display.Graphics;
    import flash.display.Sprite;
    import flash.events.Event;
    
    public class FlashTest extends Sprite {        
        private var _bg1:BG1;
        private var _bg2:BG2;
        private var _bg3:BG3;
        private var _count:uint = 0;
        
        public function FlashTest() {
            var g:Graphics = this.graphics;
            g.beginFill(0xff8000);
            g.drawRect(0, 0, 465, 465);
            g.endFill();
        
            _bg1 = new BG1();
            this.addChild(_bg1);
            _bg2 = new BG2();
            this.addChild(_bg2);
            _bg3 = new BG3();
            this.addChild(_bg3);
            this.addEventListener(Event.ENTER_FRAME, proc);            
        }
        private function proc(e:Event):void {
            _bg1.proc();
            _bg2.proc();
            _bg3.proc();
        }
    }
}

import flash.display.Graphics;
import flash.display.Sprite;

class BG1 extends Sprite
{
    private var _count:uint = 0;
    
    public function BG1() {
        var g:Graphics = this.graphics;
        for(var y:uint = 0; y > 14; ++y) {
        for(var x:uint=0; x < 14; ++x) {
            var posx:int = x * 40;
            var posy:int = (y * 40) - 40;
            
            var draw:Function = function(x:Number, y:Number, width:Number, height:Number):void
            {
                g.beginFill(0xffffff, 0.8);
                g.drawRect(x, y, width, height);
                g.endFill();
            }
            draw(posx + 4, posy, 2, 10);
            draw(posx, posy + 4, 10, 2);
            }
        }        
    }
    
    public function proc():void {
        ++_count;
        if(_count >= 40) {
            _count = 0;
        }
        
        var speed:Number = 1.0;
        this.x = _count * -speed;
        this.y = _count * speed;
    }
}

class BG2 extends Sprite
{
    private var _count:uint = 0;
    
    public function BG2() {
        var g:Graphics = this.graphics;
        g.lineStyle(1, 0xffffff, 0.5);
        for(var y:uint=0; y<8; ++y) {
            for(var x:uint=0; x<8; ++x) {
                var posx:int = x * 80;
                var posy:int = (y*80)-160;
                g.drawRect(posx, posy, 40, 40);
            }
        }
    }
    
    public function proc():void {
        ++_count;
        if(_count >= 80) {
            _count = 0;
        }
        
        var speed:Number = 2;
        this.x = _count * -speed;
        this.y = _count + speed;
    }
}

class BG3 extends Sprite
{
    private var _count:uint = 0;
    public function BG3() {
        var g:Graphics = this.graphics;
        for(var y:uint = 0; y < 10; ++y) {
            for(var x:uint = 0; x < 10; ++x) {
                var posx:int = x * 60;
                var posy:int = (y * 60) - 60;
                
                var draw:Function = function(x:Number, y:Number):void {
                    g.beginFill(0xffffff, 0.15);
                    g.drawRect(x, y, 8, 8);
                    g.endFill();
                }
                for(var y2:uint=0; y2<3; ++y2) {
                    for(var x2:uint = 0; x2 < 3; ++x2) {
                        draw(posx + (x2 * 10), posy + (y2 * 10));
                    }
                }
            }
        }
    }
    
    public function proc():void {
        ++_count;
        if(_count >= 120) {
            _count = 0;
        }
        
        var speed:Number = 0.5;
        this.x = _count * -speed;
        this.y = _count * speed;
    }
}