Table of Contents

uiLink

Required: Aspire UI Components Lite Edition v1.2.0+

The uiLink control is used to display a text that behaves like a HTML anchor link. It is a subclass of uiButton and contains a uiText instance.


Using uiLink

var link:uiLink = new uiLink();
link.text = "this is a link";
link.url = "http://ghostwire.com";
link.target = "_blank";
link.move(10, 10);
addChild(link);

uiLink example


Text Styles

By default, when using the default skins shipped with the lirbary, the textStyle property of uiLink instances will be mapped to “link”. You can modify this “link” style via the uiTextStyles manager:

uiTextStyles.manager.setStyle("link", {color:"#0000FF", textDecoration:"none" } );
uiTextStyles.manager.setStyle("link_over", {color:"#FF0000", textDecoration:"underline" } );

uiLink example

Alternatively, you can also modify/set these styles in the text.css CSS file in the respective skins folder.

link
{
    color:#000000;
    text-decoration:none;
}
 
link_over
{
    color:#0000FF;
    text-decoration:underline;
}


URL

The url property indicates URL to associate with the uiLink instance. The URL can be either absolute or relative to the location of the SWF file that is loading the page. An example of an absolute reference to a URL is http://www.ghostwire.com; an example of a relative reference is /index.html. Absolute URLs must be prefixed with http://; otherwise, Flash treats them as relative URLs.


Event

If the url is prefixed with “event:”, the instance will dispatch a TextEvent.LINK event instead of opening a URL. For example, if you set the url to “event:myText”, when the user clicks the uiLink instance, it will dispatch a TextEvent.LINK event with its text property set to “myText” (everything that comes after “event:”). You must listen to this TextEvent.LINK event and handle the event to make the instance useful.

link.url = "event:someText";
 
link.addEventListener(TextEvent.LINK, on_linkEvent);
 
function on_linkEvent(evt:TextEvent):void
{
    trace(evt.text); // output someText
}


API Reference

For more information on the members of the com.ghostwire.ui.controls.uiLink class, please refer to the API Reference.