利用TLF给文本加样式

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:ns1="*"   
   >

<fx:Script>
<![CDATA[
import flashx.textLayout.elements.ParagraphElement;
import flashx.textLayout.elements.SpanElement;
import flashx.textLayout.elements.TextFlow;

import mx.collections.ArrayList;
import mx.effects.IAbstractEffect;
import mx.managers.PopUpManager;

private function showWindow():void
{
var nFun:NewFunction=NewFunction(PopUpManager.createPopUp(this,NewFunction,true));
PopUpManager.centerPopUp(nFun);
}

protected function  showText(event:Event):void
{
var textFlow:TextFlow = new TextFlow();
var p:ParagraphElement = new ParagraphElement();
var span1:SpanElement = new SpanElement();
var span2:SpanElement = new SpanElement();
span1.text = "Hello,World! ";
span2.text = "This is a multiline, editable Spark TextArea control";
span2.fontSize = 45;
span2.color = 0xff0000;
p.addChild(span1);
p.addChild(span2);
textFlow.addChild(p);
text.textFlow = textFlow;
}

]]>
</fx:Script>

<s:layout>
<s:BasicLayout />
</s:layout>

<s:Panel title="Spark TextArea Control Example"
horizontalCenter="0"
verticalCenter="0">
<s:VGroup left="10" right="10" top="10" bottom="10">
<s:TextArea id="text" width="100" height="100">
<!--<s:text>This is a multiline, editable Spark TextArea control. If you need a non-editable multiline control, use the Text control.</s:text>-->
</s:TextArea>
<s:Button label="text" click="showText(event)"/>
<s:Button label="弹出" click="showWindow()"/>
</s:VGroup>
</s:Panel>



</s:WindowedApplication>

你可能感兴趣的:(xml)