RSS twitter

Flash Actionscript getURL

In Actionscript  and Actionscript 2  it is really easy.

Example:

getURL(“http://domain.com/webpage.html”,”_blank”);


But the easiest way is to do it in Actionscript 3.0  is textfield.htmlText

htmlText code

var link:TextField = new TextField();
link.htmlText = “<a href=’http://domain.com’>SomeDomain</a>”;
addChild(link);

setStyle

What about making the text blue AND underlined like a normal HTML link, how would one go about doing that.
Use a StyleSheet.

var style:StyleSheet = new StyleSheet();
var link:TextField = new TextField();
style.setStyle(“A”,{textDecoration:”underline”, color:”#0000FF”, fontSize:”24″, fontFamily:”Arial”, fontWeight:”bold” });
link.styleSheet = style;
link.width = 280;
link.htmlText = “<a href=’http://domain.com’>Domain.com</a>”;
addChild(link);

Other Alternatives

If the flash file is running on localhost  (and not hosted off the internet) One would need to get permission from the user (change the settings) to go to the internet. A minor point. Additionally one would need to change the mouse cursor when it rolls over the text to show that it is clickable.

public function Loader()
{
var link:TextField = new TextField();
link.text = “Domain.com”;
link.addEventListener(MouseEvent.CLICK, clickLink);
addChild(link);
}

function clickLink(e:MouseEvent)
{
navigateToURL(new URLRequest(‘http://domain.com’), ‘_blank’);
}

Similar Posts:

One Comment

  1. [...] is the original: Flash Actionscript getURL | Flash tutorials | Flash video | Flash … [...]

Leave a Reply