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 178ep3 05 May 2009
package 
{ 
    import flash.display.Sprite;
    import flash.events.Event; 
    import flash.filters.BlurFilter;
    import flash.filters.GlowFilter;
     
[SWF(width=465, height=465, frameRate=30, backgroundColor=0x000000)] 
    public class Fire extends Sprite 
    { 
        private var _stg:Sprite;
	private var _bStg:Sprite;
        private var _list:Array = []; 
		
        public function Fire() 
        { 
	    _bStg = new Sprite();
	    addChild(_bStg);
			
            _stg = new Sprite(); 
            _bStg.addChild(_stg); 
	    _stg.filters = [new GlowFilter(0xff2000,1,5,10,2,3)];
            _bStg.filters = [new BlurFilter(5,10,3)]; 
			
            addEventListener(Event.ENTER_FRAME,loop); 
        } 
         
        private function loop(e:Event):void 
        { 
            for(var j:uint=0; j<20; j++) 
            { 
                var pc:Par = new Par(mouseX,mouseY); 
                _stg.addChild(pc); 
                _list.push(pc); 
            } 
             
            var len:int = _list.length-1; 
            for (var i:int = len; i>-1; i--) 
            { 
                if (!_list[i].move()) 
                { 
                    _stg.removeChild(_list[i]); 
                    _list[i] = null; 
                    _list.splice(i, 1); 
                } 
            } 
        } 
    } 
} 
    import flash.display.Sprite; 
    import flash.display.Shape; 
    import flash.filters.BlurFilter;
    import flash.geom.ColorTransform;
    import flash.utils.ByteArray;
	
    class Par extends Sprite 
    { 
        private var _p:Shape; 
        private var _vx:Number; 
        private var _vy:Number; 
        private var _r:Number; 
        private var _fric:Number = 0.7; 
	private var _gN:uint = Math.random()*80+100;
	private var _ct:ColorTransform;
        private var _cx:uint; 
        private var _a:int = 0;
         
        public function Par(sx:Number,sy:Number) 
        { 
            _p = new Shape(); 
            addChild(_p); 
            _ct = new ColorTransform();
            _p.x = sx; 
            _p.y = sy; 
            _p.graphics.beginFill(0xffaa00); 
            _p.graphics.drawCircle(0,0,5); 
            _p.graphics.endFill(); 
             
            var rad:Number = Math.random() * 360 * Math.PI /180; 
            _r = Math.random() * 10; 
            _vx = Math.cos(rad) * _r*0.9; 
            _vy = Math.sin(rad) * _r;
   	    _cx = mouseX;
        } 
         
        public function move():Boolean 
        { 
			var bytes:ByteArray = new ByteArray();
			bytes.writeByte(0);
			bytes.writeByte(Math.random()*55+200);
			if (_a > 3)
			{
				_gN -= ((_gN-30)/(40-3));
				bytes.writeByte(_gN);
				bytes.writeByte(30);
			}
			else
			{
				bytes.writeByte(_gN+75);
				bytes.writeByte(100);
			}
			bytes.position = 0;
			var color:uint = bytes.readUnsignedInt();
			_ct.color = color;
			
			_p.transform.colorTransform = _ct;
            _p.x -= _vx;
	    _p.x -= ((_p.x - _cx)*0.02);
            _p.y += _vy - 3;
            _vx *= 0.8; 
            _vy *= _fric; 
            _p.alpha = 0.8 - (_a/50); 
            _a++; 
			
            if(_a>40) 
            { 
                return false; 
            } 
                return true; 
        }     
    }