http://www.myflexhero.com/share/flex-hero-flex4/flex-hero-components/flex-hero-style/flex-hero-filters/962
上面的連結是教學我們如何在label上增加文字濾鏡
那我們要如何在按鈕上增加文字濾鏡呢?
主要就是要在按鈕生成後抓取裡面的文字元件然後增加濾鏡效果
1 |
btn.addEventListener(FlexEvent.CREATION_COMPLETE,addFilter); |
抓取button的label的方式是下面這行
1 |
((e.target as Button).getChildAt(1) as TextField).filters = myFilters; |
所以整個函數可能如下
1 2 3 4 5 6 7 8 9 |
import flash.filters.*; //增加文字陰影 private function addFilter(e:Event):void{ var f:DropShadowFilter = new DropShadowFilter(3,30,0x000000,.8); var myFilters:Array = new Array(); myFilters.push(f); ((e.target as Button).getChildAt(1) as TextField).filters = myFilters; } |