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

forked from: forked from: モザイクでフェードイン/フェードアウト

モザイクフェードアウト→入替→モザイクフェードイン
の繰り返し。
色つけるだけという変更
// forked from HaraMakoto's forked from: モザイクでフェードイン/フェードアウト
package {
	import flash.display.Sprite;
	import flash.events.Event;
	
	[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="60")]
	/**
	 * モザイクフェードアウト→入替→モザイクフェードイン
	 * の繰り返し。
	 * 色つけるだけという変更
	 */

	public class fadeMosaic extends Sprite
	{
		private var Layer_a:Sprite = new Sprite();
		private var Layer_b:Sprite = new Sprite();
		private var shapeObj:Sprite = new Sprite();
		private var mosaicMC:mosaicFader;
		private var W:Number = 465;
		private var H:Number = 465;
		//private var W:Number = 800;
		//private var H:Number = 450;
		private var mosCounter:uint = 0;
		
		public function fadeMosaic()
		{
			addChildAt(Layer_a,0);
			addChildAt(Layer_b,1);
			Layer_a.addChild(shapeObj);
			setImg();
			setMosaicLayer();
			mosaicMC.addEventListener("mosaicComp", mosaicCompHandler);
			mosaicMC.mosaicFromTo(1,50,Layer_a, 2, 1);
			addEventListener(Event.ENTER_FRAME, HandleEnterFrame);
		}
		private function mosaicCompHandler(e:Event):void
		{
			if(mosCounter%2==1){
				mosaicMC.mosaicFromTo(1,50,Layer_a, 2, 0);
			} else {
				mosaicMC.mosaicFromTo(50,1,Layer_a, 2, 0);
				setImg();
			}
			mosCounter++;
		}
		private function setImg():void
		{
			shapeObj.x = W/2;
			shapeObj.y = H/2;
			shapeObj.graphics.clear();
			for( var i:uint=0; i<10; i++ )
			{
				shapeObj.graphics.beginFill(0xffffff);
				shapeObj.graphics.drawCircle(-W/2+W*Math.random(),-H/2+H*Math.random(),100*Math.random());
				shapeObj.graphics.endFill();
			}
		}
		private function HandleEnterFrame(e:Event):void
		{
			shapeObj.rotation += 1;
		}
		
		private function setMosaicLayer():void
		{
			mosaicMC = new mosaicFader(W, H)
			Layer_b.addChild( mosaicMC );
			mosaicMC.x = W / 2;
			mosaicMC.y = H / 2;
		}
		
	}
}
	import flash.display.Sprite;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Matrix;
	import caurina.transitions.Tweener;
	import flash.events.Event;
	

class mosaicFader extends Sprite
{
	private var bmp:Bitmap;
	private var bmpData:BitmapData;
	private var Mtx:Matrix;
	private var W:Number, H:Number;
	public var scaleNum:uint = 10; //モザイクの拡大率
	
	public function mosaicFader(pw:Number, ph:Number)
	{
		W = pw;
		H = ph;
		bmpData = new BitmapData(1,1);
		bmp = new Bitmap(bmpData);
		addChild(bmp);
		bmp.x = -W / 2;
		bmp.y = -H / 2;
	}
	
	public function setMosaic(mc:Sprite):void
	{
		Mtx = new Matrix();
		Mtx.scale( 1/scaleNum, 1/scaleNum );
		bmpData = new BitmapData( W/scaleNum, H/scaleNum, false, 0x000000 );
		bmpData.draw( mc, Mtx );
		bmp.bitmapData = bmpData;
		bmp.scaleX = W/bmpData.width;
		bmp.scaleY = H/bmpData.height;
	}
	
	public function mosaicFromTo(n1:uint, n2:uint, mc:Sprite, t:Number, d:Number):void
	{
		scaleNum = n1;
		Tweener.addTween(this, {time:t, scaleNum:n2, onUpdate:setMosaic, onUpdateParams:[mc], 
		transition:"easeOutQuint", onComplete:mosaicComplete, delay:d});
	}
	private function mosaicComplete():void
	{
		dispatchEvent(new Event("mosaicComp"));
	}
	
	
}