newirisinstance.as

来自「《Flex第一步:基于ActionScript 3.0的Flex 2应用开发》采」· AS 代码 · 共 70 行

AS
70
字号
package tree
{
	import mx.effects.effectClasses.MaskEffectInstance
	
	import mx.controls.SWFLoader;
	
	public class NewIrisInstance extends MaskEffectInstance	{
		
		public var position:String;
		
		public function NewIrisInstance(target:Object)	{	
			super(target);			
		}
		
		//*
		override protected function initMaskEffect():void{
			
			super.initMaskEffect();
	
			var targetWidth:Number = targetVisualBounds.width / Math.abs(target.scaleX);
			var targetHeight:Number = targetVisualBounds.height / Math.abs(target.scaleY);
		
			if (target is SWFLoader){
				targetWidth = target.contentWidth;
				targetHeight = target.contentHeight;		
			}
			if (showTarget){
				
				scaleXFrom = 0;
				scaleYFrom = 0;
				scaleXTo = 1;
				scaleYTo = 1;
				
				if(position == "leftTop"){
					xFrom = targetVisualBounds.x;
					yFrom = targetVisualBounds.y;
				}else if(position == "rightBottom"){
					xFrom = targetWidth+ targetVisualBounds.x;
					yFrom = targetHeight + targetVisualBounds.y;
				}else{
					xFrom = targetWidth / 2 + targetVisualBounds.x;
					yFrom = targetHeight / 2 + targetVisualBounds.y;
				}
				
				xTo = targetVisualBounds.x;
				yTo = targetVisualBounds.y;
			}else{
				scaleXFrom = 1;
				scaleYFrom = 1;
				scaleXTo = 0;
				scaleYTo = 0;
			
				xFrom = targetVisualBounds.x;
				yFrom = targetVisualBounds.y;
				
				if(position == "leftTop"){
					xTo = targetVisualBounds.x;
					yTo = targetVisualBounds.y;
				}else if(position == "rightBottom"){
					xTo = targetWidth + targetVisualBounds.x;
					yTo = targetHeight + targetVisualBounds.y;
				}else{
					xTo = targetWidth / 2 + targetVisualBounds.x;
					yTo = targetHeight / 2 + targetVisualBounds.y;
				}
			}
		}

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?