【发布时间】:2012-08-29 10:16:40
【问题描述】:
如何为组件 TextArea (Spark 4) 中的所有字母添加效果(阴影、发光)?
【问题讨论】:
-
也许我不清楚。我建议您可以使用已经具有您想要添加为字体一部分的效果的自定义字体。
标签: actionscript-3 apache-flex mxml
如何为组件 TextArea (Spark 4) 中的所有字母添加效果(阴影、发光)?
【问题讨论】:
标签: actionscript-3 apache-flex mxml
我看到这是一个老问题,但是由于我今天遇到了同样的问题,所以我发布了我的解决方案。
您可以使用textDisplay 访问TextArea 的RichEditableText 组件,如here 所述:
RichEditableText 可以作为 textDisplay 和 Scroller 访问 作为滚动条
RichEditableText是从UIComponent扩展而来的,所以filters可以应用到UIComponents("You can apply filters to any visual component that is derived from UIComponent")上。
例如,为了将DropShadowFilter 应用于组件myTextArea:TextArea 中的所有字母,我使用了以下代码行:
var richTextComponent:UIComponent = myTextArea.textDisplay as UIComponent;
var shadow:spark.filters.DropShadowFilter = new spark.filters.DropShadowFilter;
richTextComponent.filters = [shadow];
希望这对某人有所帮助:-)
【讨论】:
我不认为你可以使用 Flex 来做到这一点(或者至少我从来没有)。您需要使用 AS3 来完成
<s:Label id="label1" text="Shadow Me" />
<fx:Script>
<![CDATA[
import flash.filters.*;
private function creationComplete():void{
var dropshadow:DropShadowFilter = new DropShadowFilter( 3,90,0x000000,.5,4,4,3,3 );
this.label1.filters = [ dropshadow ];
}
]]>
</fx:Script>
【讨论】:
contentBackgroundAlpha="0" borderVisible="false"
【讨论】:
通过使用 Filter 类,我们可以为 s:TextArea 组件应用阴影发光效果。示例代码为:
<s:TextArea contentBackgroundAlpha="0" borderAlpha="0">
<s:filters>
<s:DropShadowFilter distance="5" angle="45" color="#666666"/>
</s:filters>
<s:content>
Testing text area content
</s:content>
</s:TextArea>
请参阅链接http://www.roseindia.net/tutorial/flex/flex4/components/filters.html 以应用更多滤镜(DropShadowFilter、GlowFilter、BlurFilter 和 BevelFilter)。
【讨论】:
只需为您的 TextArea 组件添加一个皮肤,然后为皮肤内的 RichEditableText 添加一个阴影。
<fx:Declarations>
<s:DropShadowFilter id="shadow2"/>
</fx:Declarations>
<s:RichEditableText id="textDisplay" heightInLines="10" widthInChars="15" filters="{[shadow2]}"/>
它对我有用,您只需调整阴影以获得漂亮的外观。
【讨论】: