用as做濾鏡效果,每種濾鏡效果對(duì)應(yīng)一個(gè)類別,這些類別將來(lái)會(huì)在Macromedia\Flash 8\語(yǔ)系\First Run\Classes\FP8\flash\filters 這個(gè)資料夾中找到說(shuō)明檔 一、漸變斜角——GradientBevelFilter類別 二、投影——DropShadowFilter類別 三、模煳——BlurFilter類別(這個(gè)最容易了,參數(shù)少) 四、光暈——GlowFilter類別 五、漸層光暈——GradientGlowFilter類別 六、斜角——BevelFilter類別 做法是用new關(guān)鍵字新建一個(gè)相應(yīng)類的對(duì)象,暫時(shí)就叫myfilters吧,然后把這個(gè)對(duì)象增加進(jìn)一個(gè)數(shù)組filters_array,最后把這個(gè)數(shù)組賦值給mc的fliters屬性,大功告成。 我想其中關(guān)鍵應(yīng)該就是建立對(duì)像時(shí)如何設(shè)定里面的參數(shù)吧,我想濾鏡的面板大家都很熟悉的了,那么,我就把a(bǔ)s增加濾鏡的一些參數(shù)和它們的面板相對(duì)照,這樣可能更容易理解。 下面逐個(gè)舉例(都是輔助里的范例啦,里面的參數(shù)名字都是可以改的,不過(guò)我覺(jué)得就用那些名字就蠻好),范例里都有函數(shù)setUpFlatRectangle(也有叫createRectangle的),是用來(lái)做一個(gè)方形mc的。 function setUpFlatRectangle(w:Number, h:Number, bgColor:Number, name:String):MovieClip { var mc:MovieClip = this.createEmptyMovieClip(name, this.getNextHighestDepth()); mc.beginFill(bgColor); mc.lineTo(w, 0); mc.lineTo(w, h); mc.lineTo(0, h); mc.lineTo(0, 0); return mc; }直接把Script復(fù)制到主場(chǎng)景的第一影格就ok了,不要忘記上面的函數(shù)哦,要注意改函數(shù)名的 一、漸變斜角——GradientBevelFilter類別 Script: import flash.filters.GradientBevelFilter; import flash.filters.BitmapFilter; var art:MovieClip = setUpFlatRectangle(150, 150, 0xCCCCCC, "gradientBevelFilterExample"); //建立新的mc,實(shí)例名:art var distance:Number = 5; var angleInDegrees:Number = 225; // opposite 45 degrees var colors:Array = [0xFFFFFF, 0xCCCCCC, 0x000000]; var alphas:Array = [1, 0, 1]; var ratios:Array = [0, 128, 255]; var blurX:Number = 8; var blurY:Number = 8; var strength:Number = 2; var quality:Number = 3; var type:String = "inner"; var knockout:Boolean = true;//設(shè)定各個(gè)參數(shù) var filter:GradientBevelFilter = new GradientBevelFilter(distance, angleInDegrees, colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout);//建立斜角濾鏡對(duì)像filter var filterArray:Array = new Array(); filterArray.push(filter); //把filter增加進(jìn)數(shù)組filterArray,如果art上有多個(gè)濾鏡效果,就直接增加進(jìn)這個(gè)數(shù)組好了 art.filters = filterArray;//將art的filters屬性設(shè)定為filterArray 下面是Script中的參數(shù)和面板中的參數(shù)對(duì)比 colors、alphas、ratios用來(lái)控制漸變顏色的,colors是色彩,alphas是百分比(這里面是0~1的小數(shù)),ratios是偏移量0~255(可以參考Color類)blurX、blurY是就對(duì)應(yīng)面板里的模煳x、模煳y。strength是面板里的強(qiáng)度,是0~255的數(shù);quality是品質(zhì),只有1、2、3分別對(duì)應(yīng)低、中、高distance是距離,預(yù)設(shè)4.0;type是類型,用字串表示,范例中的」inner」是內(nèi)側(cè),還有outer、fuller;knockout是個(gè)布爾值,表示是否挖空 二、投影——DropShadowFilter類別 import flash.filters.DropShadowFilter; var art:MovieClip = createRectangle(100, 100, 0x003366, "gradientGlowFilterExample"); var distance:Number = 20; var angleInDegrees:Number = 45; var color:Number = 0x000000; var alpha:Number = 0.8; var blurX:Number = 16; var blurY:Number = 16; var strength:Number = 1; var quality:Number = 3; var inner:Boolean = false; var knockout:Boolean = false; var hideObject:Boolean = false; var filter:DropShadowFilter = new DropShadowFilter(distance, angleInDegrees, color, alpha, blurX, blurY, strength, quality, inner, knockout, hideObject); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray;下面是Script中的參數(shù)和面板中的參數(shù)對(duì)比 Distance是距離; angleInDegrees是角度0~360 blurX、blurY是模煳x、模煳y strength是強(qiáng)度,Script里是0~5的數(shù) quality是品質(zhì),只能是1、2、3,分別對(duì)應(yīng)低、中、高 inner是內(nèi)側(cè)陰影 knockout是挖空 hideObject是隱藏對(duì)像 三、模煳——BlurFilter類別(這個(gè)最容易了,參數(shù)少嘛) import flash.filters.BlurFilter; var rect:MovieClip = createRectangle(100, 100, 0x003366, "BlurFilterExample"); var blurX:Number = 30; var blurY:Number = 30; var quality:Number = 3; var filter:BlurFilter = new BlurFilter(blurX, blurY, quality); var filterArray:Array = new Array(); filterArray.push(filter); rect.filters = filterArray;四、發(fā)光——GlowFilter類別 import flash.filters.GlowFilter; var rect:MovieClip = createRectangle(100, 100, 0x003366, "gradientGlowFilterExample"); var color:Number = 0x33CCFF; var alpha:Number = .8; var blurX:Number = 35; var blurY:Number = 35; var strength:Number = 2; var quality:Number = 3; var inner:Boolean = false; var knockout:Boolean = false; var filter:GlowFilter = new GlowFilter(color, alpha, blurX, blurY, strength, quality, inner, knockout); var filterArray:Array = new Array(); filterArray.push(filter); rect.filters = filterArray;五、漸變發(fā)光——GradientGlowFilter類別 import flash.filters.GradientGlowFilter; var art:MovieClip = createRectangle(100, 100, 0x003366, "gradientGlowFilterExample"); var distance:Number = 0; var angleInDegrees:Number = 45; var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF]; var alphas:Array = [0, 1, 1, 1, 1]; var ratios:Array = [0, 63, 126, 255]; var blurX:Number = 50; var blurY:Number = 50; var strength:Number = 2.5; var quality:Number = 3; var type:String = "outer"; var knockout:Boolean = false; var filter:GradientGlowFilter = new GradientGlowFilter(distance, angleInDegrees, colors, alphas, ratios, blurX, blurY, strength, quality, type, knockout); var filterArray:Array = new Array(); filterArray.push(filter); art.filters = filterArray; 這里的參數(shù)跟光暈的類別很像,需要說(shuō)明的就是用來(lái)設(shè)定顏色的那幾個(gè)數(shù)組里的4項(xiàng)依次是表示從外到內(nèi)的顏色的 六、斜角——BevelFilter類別 import flash.filters.BevelFilter; var distance:Number = 5; var angleInDegrees:Number = 45; var highlightColor:Number = 0xFFFF00; var highlightAlpha:Number = 1; var shadowColor:Number = 0x0000FF; var shadowAlpha:Number = 1; var blurX:Number = 10; var blurY:Number = 10; var strength:Number = 2; var quality:Number = 3; var type:String = "inner"; var knockout:Boolean = false; var filter:BevelFilter = new BevelFilter(distance, angleInDegrees, highlightColor, highlightAlpha, shadowColor, shadowAlpha, blurX, blurY, strength, quality, type, knockout); var rect:MovieClip = createRectangle(100, 100, 0x00CC00, "bevelFilterExample"); rect.filters = new Array(filter);參數(shù): highlightColor、highlightAlpha設(shè)定加亮顏色 shadowColor、shadowAlpha設(shè)定陰影顏色 |