blob: 81a8423c32c4c53335205b4cc201295829de58ad [file] [log] [blame]
<?xml version="1.0"?>
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
<fx:XML id="textFlowAsXML" source="MyTextFlow.xml" />
@namespace "library://";
Label {
baseColor: #000000;
fontFamily: "Verdana";
fontSize: "12";
advancedAntiAliasing: true;
import flashx.textLayout.conversion.TextConverter;
import flashx.textLayout.elements.TextFlow;
import spark.components.RichEditableText;
import spark.utils.TextFlowUtil;
XML.ignoreWhitespace = false;
private function init():void {
// Creates a TextFlow by importing a String containing the markup language used by the Text Layout Framework.
// If you specify it, don't forget the namespace -> xmlns=""
var markup:String = "<TextFlow xmlns=''><p fontFamily='Arial'>This is TLF markup with paragraphs.</p><p color='0x663399'>The root TextFlow tag is inlcuded.</p></TextFlow>";
rt1.textFlow = TextFlowUtil.importFromString(markup);
// This next string shows that if the root TextFlow tag is omitted, it will be added for you.
markup = "<p color='0xCE267D'>This is TLF markup with paragraphs.</p><p fontSize='10' fontWeight='bold' fontFamily='Arial'>The root TextFlow tag is omitted and therefore created automatically.</p>";
rt2.textFlow = TextFlowUtil.importFromString(markup);
// This line shows how you would import plain text with no paragraph spacing
var autoMarkup:String = "This is just a plain old string that has no markup within it.";
RichEditableText(rt3.textDisplay).textFlow = TextFlowUtil.importFromString(autoMarkup);
// This example shows how you can use the TextConverter class from TLF to import HTML formatted text
// See the docs for the subset of HTML that is supported:
var myHTML:String = "<p>This is <i>HTML</i> markup.<br><b>Hello Tour de Flex Users!</b></p>";
rt4.textFlow = TextConverter.importToFlow(myHTML,TextConverter.TEXT_FIELD_HTML_FORMAT);
<s:Panel title="Importing Text using TLF and Flex 4" width="100%" height="100%">
<s:HorizontalLayout paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10"/>
<s:RichText id="rt1" width="200"/>
<s:TextArea id="rt2" width="300" height="50"/>
<s:TextInput id="rt3" width="260"/>
<s:RichEditableText id="rt4" width="200"/>
<s:RichText id="rt5" width="280"
horizontalCenter="0" verticalCenter="0" />
<s:Label width="200" verticalAlign="justify" text="This sample shows how you can use different types of text markup within
the Flex 4 components that are based on TLF through an import. This can be especially useful for dynamically loading text
that is returned from an HTTPService call at runtime for instance."/>