ActionScript 3 物体闪光方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 物体闪光方法相关的知识,希望对你有一定的参考价值。

// INCLUDES...
import flash.display.*;
import com.greensock.*;
import com.greensock.plugins.*;
////////////////////////////

public var glintMC:MovieClip = setUpGlint(objectToApplyGlintTo);

glint(glintMC, 2, 2, true);

public function setUpGlint(originalObj:*){
	var cloneBitmapData:BitmapData = new BitmapData(originalObj.width, originalObj.height, true, 0x000000);
	cloneBitmapData.draw(originalObj);
	var BmpClone:Bitmap = new Bitmap(cloneBitmapData);
	BmpClone.x = originalObj.x;
	BmpClone.y = originalObj.y;
	BmpClone.name = "BmpClone";
	
	var cloneHolder:MovieClip = new MovieClip();
	cloneHolder.addChild(BmpClone);
	addChild(cloneHolder);
	cloneHolder.name = "assetForGlinting";
	TweenLite.to(cloneHolder, 0.01, {tint:0xFFFFFF, glowFilter:{blurX:7, blurY:7, alpha:1.35, strength:1, color:0xFFFFFF}});

	var spot:MovieClip = new spotlight();
	spot.height = spot.width = originalObj.height*4;
	addChild(spot);
	spot.x = originalObj.x-(spot.width*0.75);
	spot.y = originalObj.y + originalObj.height/2;
	spot.name = "spot";
			
	originalObj.cacheAsBitmap = cloneHolder.cacheAsBitmap = spot.cacheAsBitmap = true;
	cloneHolder.mask = spot;
	
	var cloneClip:MovieClip = new MovieClip();
	cloneClip.addChild(originalObj);
	cloneClip.addChild(cloneHolder);
	cloneClip.addChild(spot);
	addChild(cloneClip);
	return cloneClip;
}

public function glint(glintReadyMC:*, Delay=0, Duration=2, leftToRight=true){
	var spot:MovieClip = glintReadyMC.getChildByName("spot");
	var assetForGlinting = glintReadyMC.getChildByName("assetForGlinting").getChildByName("BmpClone");
	var tweenAmount:Number = assetForGlinting.width + spot.width*1.5;
	if(leftToRight){
		spot.x = assetForGlinting.x - (spot.width*0.75);
	} else {
		tweenAmount *= -1;
		spot.x  = assetForGlinting.x + assetForGlinting.width + (spot.width*0.75);
	}
	TweenLite.to(spot, Duration, {delay:Delay, x:tweenAmount.toString()});
}

以上是关于ActionScript 3 物体闪光方法的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 闪光灯焦点检测

ActionScript 3 使用动态文本字段删除闪光按钮上的箭头

ActionScript 3 在闪光AS3中轨道Polkadots(交互式)

是否可以在闪光中处理冲击波物体?

ActionScript 3 从3D空间中的物体获取角度

HTML 闪光物体