silvith
silvith

Reputation: 290

firefox does not load an xml into an swf called by a parameter in the html-code (works fine in IE)

I built an excercise in flash cs5/as3. It draws its content from an xml-file. Because I want to make it easy for other people to create their own excercise based on this swf, I want the actionscript to load the xml, with the filename based on a parameter in the html code.

In this case the xml is called oef01.xml

The link would look like this: BoFlitsOefening.swf?id=oef01

And the actionscript like this:

public function Main ()
{
    //myFile is a string I declared earlier     
    myFile = LoaderInfo(this.root.loaderInfo).parameters["id"];
    myFile +=  ".xml";

    loadXml ();         
}

function loadXml ():void
{
    xmlLoader = new URLLoader(new URLRequest(bestand));
    xmlLoader.addEventListener (Event.COMPLETE,xmlLoaded);
}

function xmlLoaded (event:Event):void
{
    myList = new XML(event.target.data);
    myList.ignoreWhite = true;
}

The construction is working fine in Internet Explorer but not in Firefox. I have done internet research but I could not find an explanation or a solution I was able to apply, though the issue is known.

Upvotes: -1

Views: 219

Answers (2)

Daniel
Daniel

Reputation: 35684

Also FireFox likes to keep external sources cached, so there's a likelihood that it's loading an old file. Make sure you clear the cache after updating the xml.

there is a way of tricking it to load it fresh every time by adding some junk after, like

.../my.xml?rand=001820018

where you generate the number randomly every time, if I remember correctly

Upvotes: 0

strah
strah

Reputation: 6722

Are you testing it on the server or locally - the URL in your browser should start with http:// not file:///?

It should work fine on the internet, while locally the URLs containing ? may not resolve properly.
In that case you may use FlashVars instead - you don't need to change the AS code, just HTML/JS.

And on a side note: you may try to embed the SWF file using SWFObject - some crossbrowsers issues are caused by wrong/buggy embedding code.

Upvotes: 0

Related Questions