-1

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.

Adam Harte
  • 10,369
  • 7
  • 52
  • 85
silvith
  • 290
  • 2
  • 14
  • What is failing when you do this in Firefox? Is `parameters["id"] null? empty string? Or as pointed out below, is it loading a cached copy? etc. – Sunil D. Jun 19 '12 at 19:10
  • Thanks for your reply. The error is specified in the title of my question: the xml does not load in firefox. Next time I'll also include that in the body of the question, that will make it clearer. – silvith Jun 21 '12 at 08:14
  • Honestly, I really don't like it when people downvote a question WITHOUT explaining why. It's very unhelpful, because how can I improve when i don't know what I did wrong? – silvith Jun 21 '12 at 14:00

2 Answers2

0

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.

strah
  • 6,702
  • 4
  • 33
  • 45
  • Yes, thank you! This was exactly the problem. When I tested it online (http) it worked like a charm :) – silvith Jun 21 '12 at 08:10
0

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

Daniel
  • 34,125
  • 17
  • 102
  • 150
  • Thanks for your suggestion. I would not be able to add a random parameter to the link every time, due to the restrictions of our system (and, possibly, my knowledge of said system :) ) – silvith Jun 21 '12 at 08:16
  • you can do it inside the swf, it shouldn't be difficult, but looks like that was not the issue anyway. – Daniel Jun 21 '12 at 16:27