[Laszlo-checkins] r10972 - in openlaszlo/trunk/WEB-INF/lps/lfc: kernel/dhtml kernel/swf9 views

bargull@openlaszlo.org bargull at openlaszlo.org
Thu Sep 11 13:10:42 PDT 2008


Author: bargull
Date: 2008-09-11 13:10:37 -0700 (Thu, 11 Sep 2008)
New Revision: 10972

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
Log:
Change 20080910-bargull-UYc by bargull at dell--p4--2-53 on 2008-09-10 11:34:15
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: UPDATED: Send resource failure information

New Features:

Bugs Fixed: LPP-6956

Technical Reviewer: max
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
The kernel classes send additional information which isn't passed on to the LzView-functions.

Updates:
LzSprite (dhtml):
- don't send objects with superfluous information
LzSprite (swf9):
- accessing the loader through the event throws an IOError while dispatching an IOErrorEvent, 
  therefore moved the code to the "Complete"-Event path
- set "loadration" to 1 when data loaded completely
    

Tests:
attached testcase to bugreport



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2008-09-11 19:40:13 UTC (rev 10971)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js	2008-09-11 20:10:37 UTC (rev 10972)
@@ -1267,7 +1267,7 @@
         }
     }
     
-    this.owner.resourceloaderror({resource: this.resource});
+    this.owner.resourceloaderror();
     if (this.skiponload != true){
         // for user-loaded media
         this.__updateLoadStatus(1);
@@ -1304,7 +1304,7 @@
         }
     }
     
-    this.owner.resourceloadtimeout({resource: this.resource});
+    this.owner.resourceloadtimeout();
     if (this.skiponload != true){
         // for user-loaded media
         this.__updateLoadStatus(1);

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-09-11 19:40:13 UTC (rev 10971)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-09-11 20:10:37 UTC (rev 10972)
@@ -11,18 +11,17 @@
 
 dynamic public class LzSprite extends Sprite {
 
-      #passthrough (toplevel:true) {  
-
+#passthrough (toplevel:true) {
   import flash.display.*;
   import flash.events.*;
   import flash.ui.*;
   import flash.geom.*;
   import flash.utils.*;
   import mx.controls.Button;
-  import flash.net.URLRequest;  
+  import flash.net.URLRequest;
 }#
 
-#passthrough  {  
+#passthrough  {
 
       public var owner:* = null;
 
@@ -220,7 +219,11 @@
             var info:LoaderInfo = imgLoader.contentLoaderInfo;
             info.addEventListener(Event.INIT, loaderInitHandler);
             info.addEventListener(IOErrorEvent.IO_ERROR, loaderEventHandler);
+          } else {
+            //TODO [20080911 anba] cancel current load?
+            // imgLoader.close();
           }
+
           var res = this.resourceObj;
           if (res) {
             res.scaleX = res.scaleY = 1.0;
@@ -229,7 +232,6 @@
           imgLoader.load(new URLRequest(url));
       }
 
-
       public function loaderInitHandler(event:Event):void {
           // These progress event listeners can only be installed after the init event
           // has been received. You get an error if you try to add them before this.
@@ -239,45 +241,52 @@
           info.addEventListener(Event.OPEN, loaderEventHandler);
           info.addEventListener(Event.UNLOAD, loaderEventHandler); 
           info.addEventListener(Event.COMPLETE, loaderEventHandler);
-          info.addEventListener(HTTPStatusEvent.HTTP_STATUS, loaderEventHandler);
-          // trace(event);
+          // @devnote: From the HTTPStatusEvent reference page:
+          // > Some Flash Player environments may be unable to detect HTTP status codes; 
+          // > a status code of 0 is always reported in these cases.
+          // Http status is actually only available for the IE Flash-Plugin. 
+          //info.addEventListener(HTTPStatusEvent.HTTP_STATUS, loaderEventHandler);
       }
 
       public function loaderEventHandler(event:Event):void {
           try {
-              var loader:Loader = Loader(event.target.loader);
+              //@devnote: accessing the Loader through "event.target.loader" may 
+              // throw runtime error #2099 (at least for an IOErrorEvent):
+              // > "The loading object is not sufficiently loaded to provide this information."
+
+              //TODO [20080911 anba] set resoucewidth/height to 0 for every event?
               this.resourcewidth = 0;
               this.resourceheight = 0;
-              try {
-                  this.resourcewidth = loader.width;
-                  this.resourceheight = loader.height;
-              } catch (e) {
-              }
               if (event.type == Event.COMPLETE) {
+                  try {
+                      var loader:Loader = Loader(event.target.loader);
+                      this.resourcewidth = loader.width;
+                      this.resourceheight = loader.height;
+                  } catch (e) {
+                  }
                   this.resourceLoaded = true;
                   // Apply stretch if needed, now that we know the asset dimensions.
                   this.applyStretchResource();
                   // send events, including onload
                   sendResourceLoad();
+                  this.owner.resourceevent('loadratio', 1);
               } else if (event.type == IOErrorEvent.IO_ERROR) {
-                  // TODO [hqm 2007-12] is this the right event type? Should we be looking
-                  // at HTTP_STATUS event error codes also?
+                  //TODO [20080911 anba] how can "owner" become null here?
                   if (this.owner != null) {
-                      this.owner.resourceloaderror( event );
+                      this.owner.resourceloaderror( (event as IOErrorEvent).text );
                   }
               } else if (event.type == ProgressEvent.PROGRESS) {
-                  var ev = event;
-                  if (ev) {
-                      var lr = ev.bytesLoaded / ev.bytesTotal;
-                      if (!isNaN(lr)) {
-                          this.owner.resourceevent('loadratio', lr);
-                      }
+                  var ev:ProgressEvent = event as ProgressEvent;
+                  var lr = ev.bytesLoaded / ev.bytesTotal;
+                  if (! isNaN(lr)) {
+                      this.owner.resourceevent('loadratio', lr);
                   }
               } else if (event.type == Event.OPEN) {
                   this.owner.resourceevent('loadratio', 0);
+              } else if (event.type == Event.UNLOAD) {
               }
           } catch (error:Error) {
-              trace(error);
+              trace(event.type + " " + error);
           }
       }
       

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2008-09-11 19:40:13 UTC (rev 10971)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2008-09-11 20:10:37 UTC (rev 10972)
@@ -1678,26 +1678,26 @@
   * @access private
   * Called by the sprite when the resource load error occurs 
   */
-function resourceloaderror() {
+function resourceloaderror(e=null) {
     this.resourcewidth = 0;
     this.resourceheight = 0;
     if (this.onresourcewidth.ready) this.onresourcewidth.sendEvent(0);
     if (this.onresourceheight.ready) this.onresourceheight.sendEvent(0);
     this.reevaluateSize();
-    if (this.onerror.ready) this.onerror.sendEvent();
+    if (this.onerror.ready) this.onerror.sendEvent(e);
 }
 
 /**
   * @access private
   * Called by the sprite when the resource load timeout occurs 
   */
-function resourceloadtimeout() {
+function resourceloadtimeout(e=null) {
     this.resourcewidth = 0;
     this.resourceheight = 0;
     if (this.onresourcewidth.ready) this.onresourcewidth.sendEvent(0);
     if (this.onresourceheight.ready) this.onresourceheight.sendEvent(0);
     this.reevaluateSize();
-    if (this.ontimeout.ready) this.ontimeout.sendEvent();
+    if (this.ontimeout.ready) this.ontimeout.sendEvent(e);
 }
 
 /**



More information about the Laszlo-checkins mailing list