// 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()});
}
物体闪光方法
ActionScript3
阅读 38
收藏 0
点赞 0
评论 0
评论列表
文章目录