Monday 6 October 2008

Interesting little AS2/flash bug

Hmm, this post is more of a quick "note to self", after making a dumb mistake on a relatively simple Flash project. The issue appears to be that there is a discrepancy between the way the Flash IE Active X control and the Firefox Flash plugin handles loading XML.

As far as I can tell in the following piece of code, we should only see the trace 'we are ready to go' if the data is loaded and ready to be used.

var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success:Boolean) {
if (success) {
var intItems:String
intItems = my_xml.childNodes[0].length;
trace('we are ready to go')
}else{
trace('oops there seems to be a problem')
}
my_xml.load('myxmldocument.xml')

That does'nt seem to be the case in the IE active x control however. My project still progressed to it's main actions (on subsequent frames on the main timeline) on the success call, but without having all the XML ready to go. Firefox worked fine, but IE kept telling me that my content was undefined.

The only way round this way to check the .loaded property before progressing. This ONLY fires when everything is ready to go. Eg:

if(my_xml.loaded){
trace('Right, now we are REALLY ready to go')
}

Hope it helps...

Powered by ScribeFire.

No comments:

Post a Comment