Newer
Older
exporter / flash / skeletal / PieceSequence.as
package skeletal
{
	import flash.display.*;
	import flash.geom.*;
	public class PieceSequence
	{
		protected var piece:Piece;
		protected var overridePiece:Piece;
		public function GetOriginalPiece():Piece { return piece; }
		public function GetPiece():Piece { return overridePiece ? overridePiece : piece; }
		public function SetOverridePiece(p:Piece) { this.overridePiece = p; }
		
		public var Export:Boolean = true;
		
		//protected var centerPoint:Point;
		//public function get CenterPoint():Point { return centerPoint; }
		
		public function GetFrame(frameNum):PieceFrameInfo
		{
			if (frameNum < 1 || frameNum > frames.length) return null;
			return frames[frameNum - 1];
		}
		
		public function CopyTransformsFrom(other:PieceSequence, atDepth = null)
		{
			if (other.frames.length == this.frames.length)
			{
				for (var i = 0; i < frames.length; i++)
				{
					this.frames[i].Present = other.frames[i].Present;
					if (other.frames[i].Present)
					{
						this.frames[i].Transform = other.frames[i].Transform.clone();
						this.frames[i].Depth = (atDepth == null) ? other.frames[i].Depth : atDepth;
					}
				}
			}
		}
		
		protected var frames:Array = [];
		public function PieceSequence(piece:Piece, length) //, centerPoint:Point)
		{
			this.piece = piece;
			//this.centerPoint = centerPoint;
			for (var i = 0; i < length; i++)
			{
				frames.push(new PieceFrameInfo());
			}
		}
		
		// clip matching info
		public var BaseClip:DisplayObject = null;
		public var Name = null;
		
		public function CheckMatches(clip:DisplayObject)
		{
			if (BaseClip != null && clip == BaseClip) return true;
			if (Name != null && clip.name == null) return true;
			return false;
		}
	}
}