Flash Actionscript getURL

January 25, 2010

Actionscript 3.0 Tutorial

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’);
}

, , , , , , , ,

Subscribe

Subscribe to our e-mail newsletter to receive updates.

3 Responses to “Flash Actionscript getURL”

  1. jamil haider Says:

    Hello! dear can you tell me how to make a hyperlink on any flv video in flash cs4,cs3
    Please tell me about this ?
    Best Regard
    Jamil Haider

  2. John Clarkson Says:

    I’ve put some GET statements on a row of buttons in flash like the following but it doesn’t work quite right. What happens is this. You access the front page http://www.bornefromabove.co.uk/news/html, and you choose a button. It pops up a new browser. ONly from WITHIN this browser will it then let you navigate across the pages using one browser. Why does it pop one up to start with? But then work okay once you are inside the browser it has popped up. I just don’t get it.

    news.onRelease=function() {
    getURL(“http://www.bornefromabove.co.uk/news.html”,target=_self);
    }
    about_us.onRelease=function() {
    getURL(“http://www.bornefromabove.co.uk/About_us.html”,target=_self);
    }
    fanzone.onRelease=function() {
    getURL(“http://www.bornefromabove.co.uk/Fanzone.html”,target=_self);
    }
    shop.onRelease=function() {
    getURL(“http://www.bornefromabove.co.uk/shop.html”,target=_self);
    }
    links.onRelease=function() {
    getURL(“http://www.bornefromabove.co.uk/links.html”,target=_self);
    }
    email.onRelease=function() {
    getURL(“http://www.bornefromabove.co.uk/email.html”,target=_self);
    }

Trackbacks/Pingbacks

  1. Flash Actionscript getURL | Flash tutorials | Flash video | Flash … at Flash Designers - January 26, 2010

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

Leave a Reply