[Laszlo-checkins] r9503 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf

max@openlaszlo.org max at openlaszlo.org
Fri Jun 6 14:49:56 PDT 2008


Author: max
Date: 2008-06-06 14:49:52 -0700 (Fri, 06 Jun 2008)
New Revision: 9503

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
Log:
Change 20080606-maxcarlson-f by maxcarlson at Roboto on 2008-06-06 12:32:34 PDT
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix stretches with setResource()

Bugs Fixed: LPP-4975 - Image stretch fails after number of setSource() calls

Technical Reviewer: promanik
QA Reviewer: hminsky
Doc Reviewer: (pending)

Details: Refactor all sprite sizing logic to updateResourceSize() method.  updateResourceSize() ensures the height and width get properly reset when a resource is attached.
    
Tests: See LPP-4975.  mousing over the left image, and clicking on the right image repeatedly works in swf7/8 and dhtml.  demos/lzpix/app.lzx runs as before in swf 7 and 8.



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-06-06 21:25:40 UTC (rev 9502)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-06-06 21:49:52 UTC (rev 9503)
@@ -309,6 +309,7 @@
     }
 
     this.resource = resourceName;
+    this.updateResourceSize(true);
 }
 
 
@@ -382,18 +383,6 @@
         this.checkPlayStatus();
     }
 
-    //@field Number resourcewidth: The width of the resource that
-    //this view attached
-    //@field Number resourceheight: The height of the resource that this
-    //view attached
-    var rt = canvas.resourcetable[ mcID ];
-    if ( rt ){
-        this.resourcewidth = rt.width;
-        this.resourceheight = rt.height;
-    } else {
-        this.resourcewidth = mc._width;
-        this.resourceheight = mc._height;
-    }
     //unrolled this loop because it is called frequently
     if (this.x != 0) this.setX(this.x);
     if (this.y != 0) this.setY(this.y);
@@ -405,8 +394,7 @@
     } else if ( this.owner.visibility != "collapse" ){
         this.__LZmovieClipRef._visible = this.visible;
     }
-    // only send onload if we have a resource
-    this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: this.__LZhaser});
+    this.updateResourceSize();
 }
 
 /**
@@ -744,12 +732,21 @@
   * (before the load started) and what we really want is the size of
   * the loaded resource.
   */
-LzSprite.prototype.updateResourceSize = function ( ){
-    var mc = this.__LZmovieClipRef;
-    // Get the true size by unscaling. Note: clip scale is in percent
-    this.resourcewidth = mc._width/(mc._xscale/100);
-    this.resourceheight = mc._height/(mc._yscale/100);
-    this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: true});
+LzSprite.prototype.updateResourceSize = function (skipsend){
+    var mc = this.getMCRef();
+    this.setWidth(this.hassetwidth?this.width:null);
+    this.setHeight(this.hassetheight?this.height:null);
+    var rt = canvas.resourcetable[ this.resource ];
+    if ( rt ){
+        this.resourcewidth = rt.width;
+        this.resourceheight = rt.height;
+    } else {
+        // Get the true size by unscaling. Note: clip scale is in percent
+        this.resourcewidth = mc._width/(mc._xscale/100);
+        this.resourceheight = mc._height/(mc._yscale/100);
+    }
+
+    if (! skipsend) this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: true});
 }
 
 /**



More information about the Laszlo-checkins mailing list