We can't use rely on the FILES_LOADED event because if there are no
files to load it will never fire, so introduce a new routine that will
do an immediate callback in that case, and a deferred one otherwise.
}
}
- private function loadedImage(event:Event):void {
+ public function onFilesLoaded(callback:Function):void {
+ if (filesRequested > filesReceived) {
+ addEventListener(FileBank.FILES_LOADED, function(e:Event):void {
+ callback();
+ });
+ } else {
+ callback();
+ }
+ }
+
+ private function loadedImage(event:Event):void {
fileReceived();
}
private function httpStatusHandler(event:HTTPStatusEvent):void { }
}
}
-}
\ No newline at end of file
+}
/** Load all images referenced in the RuleSet (for example, icons or bitmap fills). */
private function loadImages():void {
- FileBank.getInstance().addEventListener(FileBank.FILES_LOADED,doIconCallback);
var filename:String;
for each (var chooser:StyleChooser in choosers) {
for each (var style:Style in chooser.styles) {
FileBank.getInstance().addFromFile(filename);
}
}
- }
-
- private function doIconCallback(e:Event):void {
- iconCallback();
+ FileBank.getInstance().onFilesLoaded(iconCallback);
}
// ------------------------------------------------------------------------------------------------