This is going to be a rant post - yeah!
If your following us on twitter, you might have noticed my tasks for yesterday:
"Quick update on the CMS then coding on the first unity game"
Well, I didn't get to the unity game part, thanks to some weird flash (bug) that wasted 5 fucking hours of my time and still is inresolved. Here's a quick rundown:
For our new german site I wrote a simple flash based menu/header which reads in an XMl and takes two params. The xml reading was all done, but I needed to pass the params from the asp.net page to the header. I decided to use loaderInfo.params for the sake of a quick and dirty solution and then it all went down the drain ...
Testing params in THE IDE doesn't work, so I published a HTML page withit (I did mention that so far the menu worked very well?).
But opening the file locally in FF 3.0.8 did do nothing ... no menu generated from xml, it just showed the background shape.
OK, lets try in IE (6, 7, and 8) and it worked just fine, params passed, menu displayed.
Chrome worked, too, same with Opera...
FUCK! Why doesn't it work in FF?
Next thing I tried was to upload the whole lot and tried it from the server - and look it worked in FF, too. ONE FUCKIN TIME! After the file was chached it quit working just like it did offline. (All other browsers still worked just fine).
FUCK!
K, let's add some outputs to the loading process - and viola the problem was quite easy to nail down ...
Here's a stripped down version of the code: (I used a document class and a single frame with a few vector shapes on it and some textfields with an embeded font only)
Code:
/**
* ...
* @author nGFX
* @version 1.0
*/
package {
// skipped imports
public class Preloader extends Sprite {
public function Preloader() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.showDefaultContextMenu = false;
stage.quality = StageQuality.HIGH;
trace("init preloader");
this.loaderInfo.addEventListener(Event.INIT, this.initDisplay);
this.loaderInfo.addEventListener(Event.COMPLETE, this.initApplication);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, this.showProgress);
}
private function initDisplay(e:Event):void {
trace("init display");
}
private function showProgress (eProgress:ProgressEvent):void {
var fPercent:Number = Math.round((eProgress.bytesLoaded / eProgress.bytesTotal ) * 100 );
trace("Loading: " + fPercent.toString());
}
private function initApplication (e:Event):void {
trace("init application");
this.loaderInfo.removeEventListener(Event.INIT, this.initDisplay);
this.loaderInfo.removeEventListener(Event.COMPLETE, this.initApplication);
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, showProgress);
trace("loading language")
Locale.loadLanguageXML("de", onLanguageFileLoaded);
}
private function onLanguageFileLoaded (bLoaded:Boolean):void {
trace("language done")
this.initMenu();
}
private function initMenu ():void {
// some code here
}
}
}
As you can see there's no magic added to that code.
Running the swf through a a html page using FF showed the following:
- init preloader
- init display
... and nothing more ....