PDA

View Full Version : how to create a link in Flash CS4


karmstrn
02-03-2009, 04:30 PM
I downloaded a trial version of Flash CS4 and have been able to find answers to most of my questions online so far, but right now I can't even find how to make a button into a link. All I want to do is be able to put in the page information that I want the button to link to. Can anyone help me with this simple problem?

SrihariCh
02-04-2009, 10:11 AM
First create a Textbox on the stage, Select type of "Dynamic text" from Properties Inspector(which is available from Window menu-> Properties->Properties),create instance for this Textbox. Now open "Actions" panel and add the following code which creates a hyperlink to open the google Homepage:

Suppose we create textbox of DynamicText with instance "textbox1_txt", then

const DOMAIN_URL:String = "http://www.google.com";
var linkTxt:TextField = new TextField(); //Temporary variable
textbox1_txt.addEventListener(TextEvent.LINK, linkHandler);

linkTxt.text = createLink(DOMAIN_URL);
textbox1_txt.htmlText=linkTxt.text;


function createLink(url:String):String
{
var link:String = "";
link = "<font color='#0000FF'><u><b><a href='event:" + url + "'>" + textbox1_txt.text + "</a></b></u></font>";
return link;
}

function linkHandler(e:TextEvent):void
{
var request:URLRequest = new URLRequest(e.text);
navigateToURL(request);
}

tabythalynne
01-30-2010, 03:56 PM
I am also trying to create a text link in Flash CS4 so I am following the last post, but I am having trouble.

I am doing alright up until "Now open actions panel and add the following code..."

When I open actions panel it says, 'Current selection can not have actions applied to it.' I'm certain I made the text dynamic and I'm certain I made an instance.

Do you know what did I might have done wrong?

deana2677
12-16-2011, 06:31 PM
Hi there - I got this AS coding to work, however, it's only good for one link, and I have seven or so links.... How would I write the codes so that I could use this for multiple links? thanks in advanced....