Search code examples
actionscript-3firefoxloaderinfo

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.


Solution

  • 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.