PDA

View Full Version : External SWF - HTML link targets


T010
11-25-2006, 02:54 PM
Hello I have this problem:

I'm making a site which has a main SWF file for the layout (navigation and such) and the content loads in an external SWF.
Now the external SWF (page1.swf) uses a .TXT file (page1.txt) which contains the actual content (text) for the page.

page1.swf contains this code:
System.useCodepage = true;
content.html = true;
myLoadVar = new LoadVars();
myLoadVar.load("content/page1.txt");
myLoadVar.onLoad = function(success){
if(success == true){
content.htmlText = myLoadVar.content;
}
};

This is all working fine, but:

I have some text in the .TXT file, that has to be linked to a .SWF file.

like this:

in the .TXT file I have this:
<a href="page2.swf">click here to go to page 2</a>

and the page2.swf file is just another .SWF file which uses yet another .TXT file (page2.txt) for the actual content.

It might sound weird or hard to understand, but it definitely works great.


The actual question is:

How do I set the target in the <a href> tag so that the 'page2.swf' loads in the same .SWF as 'page1.swf'

Right now, whatever I tried, it either opens in a new browser window, or opens in the main .SWF file.

anonymous
11-25-2006, 04:33 PM
Have you tried with the target attribute within the a href tag, as described here at the bottom of this page...

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14808

If not, then you may get it working through a call to an asfunction...

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_15639

T010
11-27-2006, 04:29 PM
Thanks, that asfunction from that second link almost works.

It says on that page:

Note: This is equivalent to assigning"<A HREF="asfunction:myFunction">Click here</A>" to an HTML-enabled text field variable.

So I added that "asfunction:myFunction" to my <a href> tag, but it won't work!

I don't think it works with external .TXT files, unless I did something wrong.

It works when I set the URL of a text block inside Flash to asfunction:myFunction, but that's not what I want. I want to have text in a TXT file, which uses HTML tags to insert markup and links etc.

so I now have this in my TXT file

<a href="asfunction:myFunction">Go to page 2</a>

but with this, nothing happens!

Someone knows how to help me?

anonymous
11-27-2006, 05:17 PM
So I added that "asfunction:myFunction" to my <a href> tag, but it won't work!

Did you define your myFunction function on the first frame of your movie, and/or is your path to it different?

T010
11-28-2006, 08:51 AM
I did define the function in the first frame of my main movie, so i'm not sure if the path is correct.
The function is defined in the _root path, so i might have to add that to "asfunction:myFunction"..
I'll have another try at it and will let u know.

EDIT
Okay I placed the function in the external SWF instead of the main SWF, and it works perfectly!

thanks!