Links in text in Actionscript 3
This is a quick tip where I will show you three methods of adding links to text.
Method 1 – Static text
This is probably the easiest and fastest method of adding links to text. Firstly, select the Text tool (t) with static text and type a message. Then go to the options sections on the properties panel, and enter the link you want to use in the links box. If you are not using Flash CS4, try looking in the properties panel for a link box like below.
Method 2 – html text
This method uses the htmlText property in the Text class to add a URL to text. Select the Text tool (T) with dynamic text. Give the instance name “myText_txt” and select the ‘Render text as Html’ button. Now open up the Actions panel and enter the following code:
myText_txt.htmlText = "testing "+"<a href = 'http://www.ilike2flash.com'>ilike2flash</a>";
If you wish to highlight the link text in a different colour, you can use the font tag like below.
myText_txt.htmlText = "testing "+"<font color = '#FF0000'><a href = 'http://www.ilike2flash.com'>ilike2flash</a></font>";
Method 3 – TextFormat
The last method uses the URL property in the TextFormat class to assign a URL link to text. Again select the Text tool (T) with dynamic text, and give the instance name “myText_txt”. Then add the following code in the Actions panel.
myText_txt.text = "ilike2flash"; var textFormat:TextFormat = new TextFormat(); textFormat.url = "http://www. ilike2flash.com"; textFormat.target = "_blank"; myText_txt.setTextFormat(textFormat);




2 comments:
Hey I used all there method how its work. In first Method 1, I am unable to find the option section in properties panel ,and I am using flash CS3.0 platform.
Method 2 and Method 3 is running fine and I learned from it.
@supriya
Look in the properties panel for a link box like the image in step 1.
Post a Comment