rss· 投稿· 设为首页· 加入收藏· 繁體版
当前位置: 火魔网 » 程序开发 » Flex

Flex4 文本超链接的使用

Adding hyperlinks with TLF

TLF-based text controls support hyperlinks with the LinkElement class. To insert a hyperlink into the TextFlow, you use the <a> tag in a <s:textFlow> tag or the default property, or create an instance of the LinkElement class.

You can only use hyperlinks in a TextFlow object in the RichEditableText control. The Spark Label and RichText controls do not support hyperlinks.

The default behavior of a LinkElement object in the text object model is to launch a new browser window and navigate to the location specified in the href property of the LinkElement object. The following example shows a basic navigation link:
 <?xml version="1.0"?>
<!-- sparktextcontrols/SimpleLinkElement.mxml -->
<s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"   
    xmlns:mx="library://ns.adobe.com/flex/mx"    
    xmlns:s="library://ns.adobe.com/flex/spark">    <s:layout>
        <s:VerticalLayout/>
    </s:layout>        <s:RichEditableText id="richTxt"
            editable="false"
            focusEnabled="false">
            <s:textFlow>
                <s:TextFlow>
                    <s:p>
                        The following link takes you to: <s:a href="http://www.adobe.com">Adobe.com</s:a>
                    </s:p>
                </s:TextFlow>
            </s:textFlow>
        </s:RichEditableText>        <s:RichEditableText id="richTxt2"
            editable="true"
            focusEnabled="false">
            <s:textFlow>
                <s:TextFlow>
                    <s:p>
                        Hold CTRL key down when using the following link: <s:a href="http://www.adobe.com">Adobe.com</s:a>
                    </s:p>
                </s:TextFlow>
            </s:textFlow>
        </s:RichEditableText>
       
</s:Application>
顶一下
(0)
踩一下
(0)