Hyperlinks in Flash

Ok here’s a good question for all you flash geeks out there. I’m puting together my portfolio site. In the portfolio section I want to be able to create links to my work in a dynamic text box.

See I’m using a dynamicaly loaded text from a txt file. Is it possible to use HTML in the txt file and have it work once loaded into flash. I want to creat the links to my portfolio work in the txt file itself. Is it possible?

yes its possible:
Have an external text file (I’ll call it “html.txt” for an example)
in the text file I’ve type this:
text=a href="http://www.kirupa.com"Kirupa/a

(enter the appropriate < and > tags)

in a frame in the movie enter the actionscript:
loadVariablesNum (“html.txt”, 1); //loads text file at level 1

make a dynamic text box after the frame where you’ve loaded the text file and call the variable field:
_level1.text //this calls the dynamically loaded text file

Make sure that the properties of the dynamic text box have the html tags toggle turned on.

I can send you some files if I didn’t make sense.

well I already have the text box and I’m already loading txt files for my home page and my about section. Here the code:

loadText = new loadVars();
loadText.load(“home.txt”);
//creating the loadVarsText function
loadText.onLoad = function() {
scroller.text = this.hometext;
};

Do I have to alter this code at all to get the link tags to work?

Also where is the button to turn on html tags? I can’t find it in the properties bar

just a bit… :wink:

loadText.onLoad = function() {
scroller.html = true;
scroller.htmlText = this.hometext;
}

should I paste that under the code I already have?

Thanks for all you help

not exactly… replace the onLoad event handler you have with the one i posted :wink:

loadText = new loadVars();
loadText.load("home.txt");
loadText.onLoad = function() {
scroller.html = true;
scroller.htmlText = this.hometext;
}

now when I’m doing the markup in the txt file do I need the <html> tags and the <body> tags? Or just the <a href> tags?

Just the <a href> tag

Since Flash only formats certain font formatting tags, your HTML and BODY tags will not be formatted, but will instead be printed out with the rest of the text.

okay I’ve got the link working. Now how do I get it to open in a new window once the link is clicked?

<A TARGET="_blank" HREF="url">linktext</A>

I believe the target attribute works in Flash as well.

Yeah it does but it would have to be target=’_blank’ as the " will give you actionscript errors.

Ah, yes you are right, I wasn’t thinking about there actually being double quotes around the whole tag, I just wrote out the HTML code.

My fault… good catch :wink:

OK I’m a little confused.

<A TARGET="_blank" HREF=“url”>linktext</A>

So do I actually type in _blank? Or do I need to put something else there? Also do I put the quotes around _blank or something else?

Just switch from double quotes to single quotes…

<A TARGET='_blank' HREF='url'>linktext</A>

wow, this forum is always full of such helpfull people!! :beam:

So now it opens in a new window. One more question. Is there a way to have the text show up underlined like a regualr hyperlink? Or should I just underline it in the txt file?

Just use the underline HTML tag.

<U>text</U>

sweet! I didn’t know if that would work. I guess I should have tried.

Font formatting tags work.


<I></I>
<U></U>
<B></B>
<BR>
<FONT FACE='font' COLOR='#000000' SIZE='1'></FONT>

Etc etc, I don’t know all the exact tags that work, but there aren’t many, so just try it out and see if it works if you aren’t sure :slight_smile:

http://www.macromedia.com/support/flash/ts/documents/htmltext.htm

:cool: thanks kax, I was being lazy and didn’t feel like looking for it.