[Laszlo-checkins] r11369 - in openlaszlo/trunk: WEB-INF/lps/lfc/kernel/swf WEB-INF/lps/lfc/kernel/swf9 WEB-INF/lps/lfc/services demos/lzpix/classes

max@openlaszlo.org max at openlaszlo.org
Tue Oct 7 00:01:26 PDT 2008


Author: max
Date: 2008-10-07 00:01:23 -0700 (Tue, 07 Oct 2008)
New Revision: 11369

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzBrowserKernel.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzBrowserKernel.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzBrowser.lzs
   openlaszlo/trunk/demos/lzpix/classes/dataman.lzx
Log:
Change 20081006-maxcarlson-v by maxcarlson at Roboto.local on 2008-10-06 23:50:37 PDT
    in /Users/maxcarlson/openlaszlo/trunk-clean
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix resource loading in lzpix for Flash 9

Bugs Fixed: LPP-7132 - SWF9: Views with resources broken after r11331

Reviewer: Technical Reviewer: andre.bargull at udo.edu
QA Reviewer: promanik

Details: swf/LzBrowserKernel.lzs, swf9/LzBrowserKernel.lzs - Add implementation of lz.Browser.loadProxyPolicy()

swf9/LzSprite.as - Add shared LoaderContext and set to laod policy files before image completion - see http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/system/LoaderContext.html#checkPolicyFile.  Set __isinternalresource after unlaod() to prevent it from being nulled out.  Be careful about removing event listeners for ENTER_FRAME events - see http://www.gskinner.com/blog/archives/2006/07/as3_resource_ma_1.html

LzBrowser.lzs - Add loadProxyPolicy() method for loading specific policy files - required by flickr - see http://www.yswfblog.com/blog/2007/08/29/flickr-now-even-more-flash-friendly/

dataman.lzx - Preload required proxy policy files to workaround Flash bug where it can't seem to handle 302 redirects!

Tests: See LPP-7132



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzBrowserKernel.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzBrowserKernel.lzs	2008-10-07 02:55:03 UTC (rev 11368)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzBrowserKernel.lzs	2008-10-07 07:01:23 UTC (rev 11369)
@@ -230,6 +230,14 @@
     Accessibility.updateProperties();
 }
 
+/**
+  * Loads a proxy policy file
+  * @keywords flashspecific
+  * @access private
+  */
+static function loadProxyPolicy (url) {
+    System.security.loadPolicyFile(url);
+}
 
 } // End of LzBrowserKernel
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzBrowserKernel.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzBrowserKernel.lzs	2008-10-07 02:55:03 UTC (rev 11368)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzBrowserKernel.lzs	2008-10-07 07:01:23 UTC (rev 11369)
@@ -17,6 +17,7 @@
 #passthrough (toplevel:true) {  
   import flash.net.*;
   import flash.system.Capabilities;
+  import flash.system.Security;
 }#
 
 /**
@@ -247,5 +248,13 @@
   throw new Error("updateAccessibility not implemented");
 }
 
+/**
+  * Updates accessibility data
+  * @keywords flashspecific
+  * @access private
+  */
+static function loadProxyPolicy (url) {
+    Security.loadPolicyFile(url);
+}
 
 } // End of LzBrowserKernel

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-10-07 02:55:03 UTC (rev 11368)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-10-07 07:01:23 UTC (rev 11369)
@@ -19,6 +19,7 @@
   import flash.utils.*;
   import mx.controls.Button;
   import flash.net.URLRequest;
+  import flash.system.LoaderContext;
   import flash.media.Sound;
   import flash.media.SoundChannel;
   import flash.media.SoundMixer;
@@ -65,6 +66,8 @@
       var resourceCache:Array = null;
 
       /* private */ static const soundLoaderContext:SoundLoaderContext = new SoundLoaderContext(1000, true);
+      /* private */ 
+      static const loaderContext:LoaderContext = new LoaderContext(true);
       /* private */ static const MP3_FPS:Number = 30;
       /* private */ var sound:Sound = null;
       /* private */ var soundChannel:SoundChannel = null;
@@ -260,6 +263,7 @@
           if (getFileType(url, filetype) == "mp3") {
               // unload previous image-resource and sound-resource
               this.unload();
+              this.__isinternalresource = false;
               this.resource = url;
               this.loadSound(url);
           } else {
@@ -272,6 +276,7 @@
                   if (this.resourceObj) {
                       this.unload();
                   }
+                  this.__isinternalresource = false;
                   imgLoader = new Loader();
                   imgLoader.mouseEnabled = false;// @devnote: see LPP-7022
                   this.resourceObj = imgLoader;
@@ -290,7 +295,7 @@
                   res.scaleX = res.scaleY = 1.0;
               }
               //Debug.write('sprite setsource load ', url);
-              imgLoader.load(new URLRequest(url));
+              imgLoader.load(new URLRequest(url), loaderContext);
           }
       }
       
@@ -329,13 +334,17 @@
               this.resourcewidth = 0;
               this.resourceheight = 0;
               if (event.type == Event.COMPLETE) {
+                  if (this.loaderMC) {
+                      this.loaderMC.removeEventListener(Event.ENTER_FRAME, updateFrames);
+                      this.loaderMC = null;
+                  }
+
                   var info:LoaderInfo = event.target as LoaderInfo;
                   if (info.content is AVM1Movie) {
                       if ($debug) {
                           Debug.warn("Playback control will not work for the resource.  Please update or recompile the resource for Flash 9.", this.resource);
                       }
-                      this.loaderMC = null;
-                  } else {
+                  } else if (info.content is MovieClip) {
                       // store a reference for playback control
                       this.loaderMC = MovieClip(event.target.content);  
 
@@ -345,6 +354,7 @@
                       this.owner.resourceevent('play', null, true);
                       this.playing = this.owner.playing = true;
                   }
+
                   try {
                       var loader:Loader = Loader(event.target.loader);
                       this.resourcewidth = loader.width;
@@ -372,7 +382,7 @@
               } else if (event.type == Event.UNLOAD) {
               }
           } catch (error:Error) {
-              trace(event.type + " " + error);
+              Debug.warn(event.type + " " + error);
           }
       }
       
@@ -1217,6 +1227,10 @@
         this.lastreswidth = this.lastresheight = this.resourcewidth = this.resourceheight = 0;
         this.resource = null;
         this.__isinternalresource = null;
+        if (this.loaderMC) {
+            this.loaderMC.removeEventListener(Event.ENTER_FRAME, updateFrames);
+            this.loaderMC = null;
+        }
         this.loaderMC = null;
         this.imgLoader = null;
         this.resourceObj = null;

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzBrowser.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzBrowser.lzs	2008-10-07 02:55:03 UTC (rev 11368)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzBrowser.lzs	2008-10-07 07:01:23 UTC (rev 11369)
@@ -160,6 +160,15 @@
   function updateAccessibility ()
     { LzBrowserKernel.updateAccessibility ();}
 
+  /**
+    * Loads a proxy policy file
+    * @keywords flashspecific
+    * @access private
+    */
+  function loadProxyPolicy (url) {
+    LzBrowserKernel.loadProxyPolicy(url);
+  }
+
   /** @access private */
   var postToLps = true;
   /** @access private */

Modified: openlaszlo/trunk/demos/lzpix/classes/dataman.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/classes/dataman.lzx	2008-10-07 02:55:03 UTC (rev 11368)
+++ openlaszlo/trunk/demos/lzpix/classes/dataman.lzx	2008-10-07 07:01:23 UTC (rev 11369)
@@ -223,6 +223,15 @@
     <!-- just for testing... -->
     <dataset name="testds" type="http" ondata="if (global['debugdata']) Debug.write('ondata', this)" />
 
+    <handler name="oninit">
+        // See http://www.yswfblog.com/blog/2007/08/29/flickr-now-even-more-flash-friendly/
+        if ($swf9) {
+            lz.Browser.loadProxyPolicy('http://farm1.static.flickr.com/crossdomain.xml');
+            lz.Browser.loadProxyPolicy('http://farm2.static.flickr.com/crossdomain.xml');
+            lz.Browser.loadProxyPolicy('http://farm3.static.flickr.com/crossdomain.xml');
+            lz.Browser.loadProxyPolicy('http://farm4.static.flickr.com/crossdomain.xml');
+        }
+    </handler>
 </library>
 
 <!--



More information about the Laszlo-checkins mailing list