Decrement icon counter during error conditions. Without this, an incorrect icon url...
authorAndy Allan <gravitystorm@gmail.com>
Thu, 11 Nov 2010 15:16:13 +0000 (15:16 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Thu, 11 Nov 2010 15:16:13 +0000 (15:16 +0000)
net/systemeD/halcyon/styleparser/RuleSet.as

index d066487b1637dccdc292917979dd476ab6803616..f45ad9b9b87266c6a07311167fa7255803d2fa5d 100644 (file)
@@ -287,8 +287,8 @@ package net.systemeD.halcyon.styleparser {
                                        loader.info['filename']=filename;
                                        loader.addEventListener(Event.COMPLETE,                                         loadedImage,                    false, 0, true);
                                        loader.addEventListener(HTTPStatusEvent.HTTP_STATUS,            httpStatusHandler,              false, 0, true);
-                                       loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,      securityErrorHandler,   false, 0, true);
-                                       loader.addEventListener(IOErrorEvent.IO_ERROR,                          ioErrorHandler,                 false, 0, true);
+                                       loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,      onImageLoadSecurityError,       false, 0, true);
+                                       loader.addEventListener(IOErrorEvent.IO_ERROR,                          onImageLoadioError,                     false, 0, true);
                                        loader.load(request.request);
                                }
                        }
@@ -311,10 +311,24 @@ package net.systemeD.halcyon.styleparser {
                        imageWidths[fn]=event.target.width;
                        // ** do we need to explicitly remove the loader object now?
 
-                       iconsToLoad--;
-                       if (iconsToLoad==0 && iconCallback!=null) { iconCallback(); }
+                       oneLessImageToLoad();
                }
 
+        private function oneLessImageToLoad():void {
+            iconsToLoad--;
+            if (iconsToLoad<=0 && iconCallback!=null) { iconCallback(); }
+        }
+
+        private function onImageLoadioError ( event:IOErrorEvent ):void {
+            trace("ioerrorevent: "+event.target.info['filename']);
+            oneLessImageToLoad();
+        }
+
+        private function onImageLoadSecurityError ( event:SecurityErrorEvent ):void {
+            trace("securityerrorevent: "+event.target.info['filename']);
+            oneLessImageToLoad();
+        }
+
                private function httpStatusHandler( event:HTTPStatusEvent ):void { }
                private function securityErrorHandler( event:SecurityErrorEvent ):void { Globals.vars.root.addDebug("securityerrorevent"); }
                private function ioErrorHandler( event:IOErrorEvent ):void { Globals.vars.root.addDebug("ioerrorevent"); }