flash on 2010-12-24

by Tamanegi_kenshi
♥0 | Line 55 | Modified 2010-12-24 08:39:04 | MIT License
play

ActionScript3 source code

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

package {
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    public class FlashTest extends Sprite {
        private var balls:Array = [];
        private var ballsLength:int = 30;
        
        public function FlashTest() {
            init();
        }//FlashTest
        private function init():void{
            for(var i:int = 0; i < ballsLength; i++){
            var ball:Ball = new Ball();
            ball.x = int(Math.random() * 465);
            ball.y = int(Math.random() * 465);
            balls.push(ball);
            addChild(ball);
            }//for
        }//init
    }//class
}
import flash.filters.BlurFilter;//package

//Ballクラス
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.geom.ColorTransform;//package
import flash.events.Event;
import flash.display.Sprite;
import flash.utils.Timer;

class Ball extends Sprite{
    private var myTimer:Timer;
    public function Ball(){
        myTimer = new Timer(1000);
        myTimer.addEventListener(TimerEvent.TIMER, onTimer);
        
        graphics.beginFill(0xcccccc);
        graphics.drawCircle(0, 0, 5);
        graphics.endFill();
        
        this.filters = [new BlurFilter(5, 5, 1)];      
        this.buttonMode = true;
        
        this.addEventListener(MouseEvent.CLICK, onClick);
        //addEventListener(Event.ENTER_FRAME, onEnter);
    }
    private function onTimer(e:TimerEvent):void{
        RedColor();
    }
    
    private function onClick(e:MouseEvent):void{
        myTimer.start();
    }

    private function onEnter(e:Event):void{
        this.x += 1;
    }
    public function RedColor():void{
        var color:uint = Math.random() * 0xffffff;
        var colorTran:ColorTransform = new ColorTransform();
        colorTran.color = color;
        this.transform.colorTransform = colorTran;
    }



}