マスクのサンプル -対角線- : ActionScript

Pocket

対角線に沿ってマスク。

function Mask()
{
	var timer:Number;
	var pieceArr:Array = [];
	var count:Number = 0;
	this.initMask = function()
	{
		var xLength = Stage.width / 20;
		var yLength = Stage.height / 20;
		var tmpArr:Array = [];
		for (var i = 0; i < xLength; i++)
		{
			for (var j = 0; j < yLength; j++)
			{
				var index = i + j;
				if (pieceArr[index] == undefined)
				{
					pieceArr[index] = [];
				}
				var o = {_x:j * 20, _y:i * 20};
				pieceArr[index][i] = this.attachMovie('piece', 'piece' + j + i, this.getNextHighestDepth(), o);
			}
		}
	};
	this.masking = function()
	{
		timer = setInterval(remove, 36);
	};
	var remove = function ()
	{
		if (count < pieceArr.length)
		{
			for (var i = 0; i < pieceArr[count].length; i++)
			{
				pieceArr[count][i].removeMovieClip();
			}
			count++;
		}
		else
		{
			clearInterval(timer);
		}
	};
}
maskProp = new Mask();
var mask = _root.attachMovie('mask', 'mask', _root.getNextHighestDepth(), maskProp);
mask.initMask();
front.setMask(mask);
mask.masking();

Part2

function Mask()
{
	// マスクに敷き詰めるパターン配列
	var patternArr:Array = [];
	var onDimCount:Number = 0;
	var twoDimCount:Number = 0;
	// パターン削除用タイマー
	var timer:Number;
	this.initMask = function()
	{
		var xLength = Stage.width / 20;
		var yLength = Stage.height / 20;
		var tmpArr:Array = [];
		for (var i = 0; i < xLength; i++)
		{
			for (var j = 0; j < yLength; j++)
			{
				var index = i + j;
				if (patternArr[index] == undefined)
				{
					patternArr[index] = [];
				}
				var o = {_x:j * 20, _y:i * 20};
				patternArr[index][i] = this.attachMovie('pattern', 'pattern' + j + i, this.getNextHighestDepth(), o);
			}
		}
	};
	this.masking = function()
	{
		timer = setInterval(remove, 24);
	};
	var remove = function ()
	{
		if (onDimCount < patternArr.length)
		{
			patternArr[onDimCount][twoDimCount].removeMovieClip();
			if (twoDimCount == patternArr[onDimCount].length)
			{
				onDimCount++;
				twoDimCount = 0;
			}
			else
			{
				twoDimCount++;
			}
		}
		else
		{
			clearInterval(timer);
		}
	};
}
maskProp = new Mask();
var mask = _root.attachMovie('mask', 'mask', _root.getNextHighestDepth(), maskProp);
mask.initMask();
front.setMask(mask);
mask.masking();

コメント

No comments yet.

コメントの投稿

改行と段落タグは自動で挿入されます。
メールアドレスは表示されません。