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

bargull@openlaszlo.org bargull at openlaszlo.org
Tue Oct 14 01:59:40 PDT 2008


Author: bargull
Date: 2008-10-14 01:59:36 -0700 (Tue, 14 Oct 2008)
New Revision: 11441

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
Log:
Change 20081013-bargull-hYz by bargull at dell--p4--2-53 on 2008-10-13 22:23:17
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: flash context menu fixes

New Features:

Bugs Fixed: LPP-5670, LPP-7146, LPP-7154

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

Documentation:

Release Notes:

Details:
LzMediaLoader:
Changed execution order so that requests are removed from the loading queue before dispatching the "onloaddone"-event
This fixes an issue from the original testcase where the last two views needed to be set to visible manually. 
LzMakeLoadSprite:
Call "updateAfterLoad()" in "setResource()", but make sure you don't send the "onload"-event on the view. But this requires you to call "doQeuedPlayAction()" manually!
With that change all four yellows in the middle column are visible. And the context-menu will work, too. And "onframe"-events are working again.
LzSprite: 
Moved all 're-apply context-menu' code into "attachResourceToChildView()" and "attachBackgroundToChild()".


    

Tests:
see testcases at bugreports



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as	2008-10-14 08:00:07 UTC (rev 11440)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as	2008-10-14 08:59:36 UTC (rev 11441)
@@ -59,6 +59,7 @@
   * @param String filetype: Filetype, e.g. 'mp3' or 'jpg'.  If not specified, it will be derived from the URL.
   */
 LzMakeLoadSprite.setSource = function (src, cache, header, filetype) {
+    // unload anything currently loading...
     if (this.loader.mc.loading == true) {
         LzLoadQueue.unloadRequest(this.loader.mc);
     }
@@ -103,7 +104,10 @@
         if (this.queuedplayaction == null) {
             this.queuePlayAction("checkPlayStatus");
         }
-        //this.updateAfterLoad();
+        // make sure resource is updated, but no "onload"-event is sent
+        this.updateAfterLoad(null);
+        // need to call manually because no "onload"-event was sent
+        this.doQueuedPlayAction();
     }
 }
 
@@ -111,9 +115,9 @@
   * Updates movieclip properties after the resource has loaded
   * @access private
   */
-LzMakeLoadSprite.updateAfterLoad = function (ignore) {
+LzMakeLoadSprite.updateAfterLoad = function (mloader) {
     this.isloaded = true;
-    
+
     var mc = this.getMCRef();
     this.resourcewidth = mc._width;
     this.resourceheight = mc._height;
@@ -132,16 +136,16 @@
     this.setHeight(this.hassetheight ? this.height : null);
     this.setWidth(this.hassetwidth ? this.width : null);
 
-    if (this.__contextmenu) {
-        this.setContextMenu(this.__contextmenu);
-    }
+    // Install right-click context menu if there is one
+    if (this.__contextmenu) mc.menu = this.__contextmenu.kernel.__LZcontextMenu();
 
-    this.owner.__LZvizLoad = true; 
+    this.owner.__LZvizLoad = true;
     this.owner.__LZupdateShown();
-    this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: false});
+    // skip event when called by setResource()
+    var skip = (mloader == null);
+    this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, 
+                                resource: this.resource, skiponload: skip});
     this.owner.reevaluateSize();
-    
-    //if (this.owner.onload) this.owner.onload.sendEvent( this.loader.mc );
 }
 
 /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs	2008-10-14 08:00:07 UTC (rev 11440)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMediaLoader.lzs	2008-10-14 08:59:36 UTC (rev 11441)
@@ -114,7 +114,7 @@
             LzLoadQueue.loadFinished( mc );
         }
     } else if ($debug) {
-        Debug.error('%w.attachMovie(%w)', this, resc);
+        Debug.error('%w.attachLoadMovie(%w)', this, resc);
     }
 }
 
@@ -124,7 +124,7 @@
  * want to access a URL which generates a supported format, but has an
  * suffix from which it is not possible to deduce the file type, like
  * .jsp or .php.
- * 
+ *
  * @access private
  */
 static var unsupportedMediaTypes = {
@@ -210,7 +210,7 @@
   * @access private
   */
 function testLoad (ignore) {
-    //skip first check because this can get called before load starts, in 
+    //skip first check because this can get called before load starts, in
     //which case load info is wrong
     //getBytesTotal is wrong before the header of the movie has loaded
 
@@ -226,7 +226,7 @@
     if (this.isjpeg && lmc._height <= 0) {
         //Debug.error('skipping 0 height jpeg');
         return;
-    }    
+    }
 
     if (this.checkonce) {
         //a swf loaded from another domain will be sandboxed. no load
@@ -283,15 +283,22 @@
                 if (loaded) {
                     //if mc.loaded is set, means returnData has already been called
                     //(probably by error swf.)
+                    var loaddone = false;
                     if (! this.mc.loaded) {
                         this.removeLoadChecker();
-                        if (this.onloaddone.ready) this.onloaddone.sendEvent( this );
+                        loaddone = true;
                     }
-                    
+
                     // TODO: [20080909 anba] send always for crossdomain loading?
                     if (! this.mc.loaded || xdomain) {
+                        // remove request from LzLoadQueue
                         this.returnData( this.mc );
                     }
+
+                    if (loaddone && this.onloaddone.ready) {
+                        // send onloaddone event after removing request from queue
+                        this.onloaddone.sendEvent( this );
+                    }
                 }
             }
         }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-10-14 08:00:07 UTC (rev 11440)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-10-14 08:59:36 UTC (rev 11441)
@@ -167,7 +167,7 @@
 // takes it's dimensions from the resource and there is no scaling.
 LzSprite.prototype.width =   0;
 LzSprite.prototype.height =   0;
-// @devnote: "LzMouseEvents" is defined in SWFFile.java
+// @devnote "LzMouseEvents" is defined in SWFFile.java
 LzSprite.prototype.__LZclickregion =  "LzMouseEvents";
 
 // @devnote Sprite scale is stored as a fraction, but the runtime clip
@@ -235,7 +235,8 @@
 /**
   * This method associates a view with a named library element. If the
   * view's <attribute>isVisible</attribute> property is true, the
-  * resource will be displayed when it is attached
+  * resource will be displayed when it is attached.
+  * May be overridden by loader.
   * 
   * @param String resourceName: a string naming the id of the resource to attach
   */
@@ -264,18 +265,14 @@
         //from this context, but it's not necessary.
         var mc = this.owner.immediateparent.sprite.attachResourceToChildView( resourceName, this );
         this.setMovieClip( mc, resourceName );
-        // Install right-click context menu if there is one
-        mc.menu = this.__contextmenu && this.__contextmenu.kernel.__LZcontextMenu();
     }
 
     this.updateResourceSize(true);
 }
 
 
-
 /**
   * @access private
-  * May be overridden by loader
   */
 LzSprite.prototype.doReplaceResource = function(resourceName) {
     if ( this.owner.subviews.length ){
@@ -288,12 +285,9 @@
     var reclick = this.__LZbuttonRef._visible;
     this.__LZbuttonRef = null;
 
-    var oldmenu = this.__contextmenu && this.__contextmenu.kernel.__LZcontextMenu();
     var oldname = this.__LZmovieClipRef._name;
-    var mc = this.owner.immediateparent.sprite.attachResourceToChildView( resourceName, this, oldname);
-
+    var mc = this.owner.immediateparent.sprite.attachResourceToChildView( resourceName, this, oldname );
     this.setMovieClip( mc, resourceName );
-    mc.menu = oldmenu;
 
     if ( reclick ){
         this.setClickable( true );
@@ -349,6 +343,8 @@
     } else if ( this.owner.visibility != "collapse" ){
         this.__LZmovieClipRef._visible = this.visible;
     }
+    // TODO: [20081013 anba] is this call necessary? 
+    // see call hierarchy (setResource -> [doReplaceResource ->] setMovieClip)
     this.updateResourceSize();
 }
 
@@ -361,7 +357,7 @@
   * @keywords flashspecific
   * 
   * @param resourceName: a string naming the resource to attach.  This is a resource defined with the <tagname>resource</tagname> tag.
-  * @param childsprite: a reference to the child sprite that the new resource will b
+  * @param childsprite: a reference to the child sprite that the new resource will be
   * attached to
   * 
   * @return: a reference to the newly attached resource
@@ -386,8 +382,10 @@
     var depth = this.FIRST_SUBVIEW_DEPTH + 
       (childsprite.__LZdepth * this.CLIPS_PER_SUBVIEW) + 
       this.FOREGROUND_DEPTH_OFFSET;
-    
+
     var newmc = this.__LZmovieClipRef.attachMovie( resourceName, instName, depth);
+    // Install right-click context menu if there is one
+    if (childsprite.__contextmenu) newmc.menu = childsprite.__contextmenu.kernel.__LZcontextMenu();
 
     return newmc;
 }
@@ -397,7 +395,6 @@
   * @access private
   */
 LzSprite.prototype.attachBackgroundToChild = function ( childsprite ){
-
     if (this.__LZmovieClipRef == null){
         this.makeContainerResource( );
     }
@@ -411,16 +408,19 @@
     var depth = this.FIRST_SUBVIEW_DEPTH +
       (childsprite.__LZdepth * this.CLIPS_PER_SUBVIEW) +
       this.BACKGROUND_DEPTH_OFFSET;
-    
+
     // @devnote _xscale, _yscale: See note at LzSprite#width for why this is correct
     var initObject = { _xscale: childsprite.width, _yscale: childsprite.height,
                         _x: childsprite.x, _y: childsprite.y,
                         _alpha: childsprite.opacity * 100, 
                         _rotation: childsprite.rotation % 360,
                         _visible: childsprite.visible && childsprite.owner.isinited };
-    
+
     var mc = this.__LZmovieClipRef.attachMovie( "swatch", "$b" + this.__LZsubUniqueNum, depth, initObject );
-    childsprite.__LZbgRef = mc;
+    // Install right-click context menu if there is one
+    if (childsprite.__contextmenu) mc.menu = childsprite.__contextmenu.kernel.__LZcontextMenu();
+
+    return mc;
 }
 
 
@@ -434,7 +434,7 @@
     if (bgc != null) {
         if ($debug) {
             if (isNaN(Number( bgc ))) {
-                Debug.write( "Invalid value for bgcolor: " + bgca, this );
+                Debug.write( "Invalid value for bgcolor on %w: %w", this, bgca );
             }
         }
         this.bgcolor = Number(bgc);
@@ -473,7 +473,7 @@
   */
 LzSprite.prototype.applyBG = function () {
     if (! this.__LZisBackgrounded) {
-        this.owner.immediateparent.sprite.attachBackgroundToChild( this );
+        this.__LZbgRef = this.owner.immediateparent.sprite.attachBackgroundToChild( this );
         this.__LZisBackgrounded = true;
     }
     var bgc = this.bgcolor;
@@ -483,10 +483,6 @@
         }
         this.__LZbgColorO.setRGB( bgc );
     }
-    // Reapply context menu if needed
-    if (this.__contextmenu) {
-        this.setContextMenu(this.__contextmenu);
-    }
 }
 
 
@@ -671,7 +667,10 @@
         this.resourceheight = Math.round(mc._height/(mc._yscale/100));
     }
 
-    if (! skipsend && ! this.__LZhaser) this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: true});
+    if (! skipsend && ! this.__LZhaser) {
+        this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight,
+                                    resource: this.resource, skiponload: true});
+    }
 }
 
 /**
@@ -815,11 +814,10 @@
   * @param String headers: Headers to send with the request, if any.
   */
 LzSprite.prototype.setSource = function ( source, cache, headers, filetype){
-    //@devnote: after this call, setSource, setResource, getMCRef and destroy have been over-ridden
+    //@devnote after this call, setSource, setResource, getMCRef and destroy have been overridden
     LzMakeLoadSprite.transform( this, source, cache, headers, filetype);
 }
 
-
 /**
   * Adds a child sprite to this sprite's display hierarchy
   * @access protected
@@ -855,6 +853,7 @@
 
 /**
   * This method should remove a view, its media, and any of its subviews.
+  * May be overridden by loader.
   * @access private
   * 
   */
@@ -1085,11 +1084,10 @@
 
     var reback = cSprite.__LZisBackgrounded;
     if (reback) {
-        var menu = cSprite.__contextmenu && cSprite.__contextmenu.kernel.__LZcontextMenu();
         var al = cSprite.__LZbgRef._alpha;
         cSprite.removeBG();
     }
-    
+
     while ((cSprite.__LZdepth + next < dl.length) && (cSprite.__LZdepth + next >= 0)) {
         var d = cSprite.__LZdepth;
         var nv = dl[ d+next ];
@@ -1114,18 +1112,15 @@
         next = dir;
 
         if ( nv.__LZisBackgrounded ){
-            var menu2 = nv.__contextmenu && nv.__contextmenu.kernel.__LZcontextMenu();
             var al2 = nv.__LZbgRef._alpha;
             nv.removeBG();
             nv.applyBG();
-            nv.__LZbgRef.menu = menu2;
             nv.__LZbgRef._alpha = al2;
         }
     }
 
     if ( reback ){
         cSprite.applyBG();
-        cSprite.__LZbgRef.menu = menu;
         cSprite.__LZbgRef._alpha = al;
     }
     return true;
@@ -1507,7 +1502,7 @@
     this.__contextmenu = cmenu;
     cmenu = cmenu.kernel.__LZcontextMenu();
 
-    if (! (this.owner == canvas || this instanceof LzTextSprite)) {
+    if (! (this.isroot || this instanceof LzTextSprite)) {
         // normal views install the context-menu on their background-clip
         var mb = this.__LZbgRef;
         if (mb == null) {
@@ -1522,7 +1517,7 @@
 
     // Install menu on foreground resource clip if there is one,
     // must use _root if canvas
-    var mc = this.owner === canvas ? _root : this.getMCRef();
+    var mc = this.isroot ? _root : this.getMCRef();
     if (mc != null) {
         mc.menu = cmenu;
     }



More information about the Laszlo-checkins mailing list