Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML linking to an external URL problem 1

Status
Not open for further replies.

carmenMiranda

Programmer
May 22, 2003
47
GB
Hi, can anyone help me with the following problem:

An SWF is embedded in an HTML page. The SWF links to an external URL via a button. The external URL is defined in an XML file, so that it can be easily updated on a regular basis.

However, if the SWF and the XML file are not placed in the same directory as the HTML page, the call to the URL doesn't work.

Code to load the XML:
var destinationURL:String;
var externalData:XML = new XML();

externalData.ignoreWhite = true;
externalData.onLoad = parse;
externalData.load("targetURL.xml");

function parse(success) {
if (success) {
destinationURL = String(this.firstChild.attributes.address);
if (destinationURL == "") {
destinationURL = " }
} else {
trace("XML document not loaded");
}
}

Code for the button:
this.clickBtn.onRelease = function() {
getURL(destinationURL, "_self");
}

Code in the XML file:
<destinationURL address="
I would really like to be able to place the SWF and the XML file together in their own directory, discreet from the HTML page into which the SWF is loaded.

Can anyone help me by explaining how I can achieve this?

Many thanks in advance.
 
Let's say you placed your SWF and XML in a folder called "flash". This "flash" folder sits next to your HTML.

When you embed the SWF in the HTML, the SWF's logical address becomes the HTML itself. So when it tries to load the XML with 'load("targetURL.xml")' the XML is not there, because XML is in "flash/targetURL.xml".

The solution is to add a "base" parameter to <object>/<embed> tags.

Example:
Code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"[/URL] width="320" height="240">
<param name="movie" value="flash/temp.swf"> 
<param name="quality" value="high">
[b]<param name="base" value="flash">[/b]
<embed src="flash/temp.swf" width="320" height="240" quality="high" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] type="application/x-shockwave-flash" [b]base="flash"[/b]></embed>
</object>


Kenneth Kawamoto
 
Thanks for the excellent and speedy reply. This is a good solution to the problem, but I think the answer you gave to my question about the SWF 'calling' the folder name it resides in is even better.

Many thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top