Flex s:Label 设立超链接

Flex s:Label 设置超链接

在Flex中,需要在label上设置一个超链接,类似与html中的超链接:

 

<a href="www.iteye.com">iteyer</a>

 

在Flex中可以如下设置,完成同样的效果:

 

<s:Label id="textLabel" buttonMode="true"
                     click="textLabel_clickHandler(event)" color="blue" text="link"
                     textDecoration="underline"/>

 

 

protected function textLabel_clickHandler(event:MouseEvent):void
{
       navigateToURL("http://www.baidu.com", "blank");   
}

 

navigateToURL(url,mode);
mode:  _self (本窗口打开), _blank(新窗口打开) , _top

 

 

另外,还可以用<s:LinkButton>,<s:LinkBar> 以及<s:RichEditableText>

 

<s:RichEditableText
            editable="false" >
            <s:textFlow>
                <s:TextFlow>
                    <s:p>
                         <s:a href="http://www.51.com">51.com</s:a>
                    </s:p>
                </s:TextFlow>
            </s:textFlow>
        </s:RichEditableText>