Author: hqm
Date: 2008-01-13 22:33:43 -0800 (Sun, 13 Jan 2008)
New Revision: 7818

Modified:
   openlaszlo/branches/devildog/WEB-INF/lps/lfc/core/dummyclasses.js
   openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LFCApplication.as
   openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
   openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
   openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LaszloView.js
   
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
Log:
Change 20080114-hqm-2 by [EMAIL PROTECTED] on 2008-01-14 01:31:17 EST
    in /cygdrive/c/users/hqm/openlaszlo/devildog
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog

Summary:  support for embedded assets

New Features:

Bugs Fixed:

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

Documentation:

Release Notes:

Details:
    
compile references to resources into flex Embed syntax, and add to
LFC resource library table


Tests:



Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/core/dummyclasses.js
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/core/dummyclasses.js   
2008-01-14 06:00:08 UTC (rev 7817)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/core/dummyclasses.js   
2008-01-14 06:33:43 UTC (rev 7818)
@@ -73,3 +73,5 @@
     }
 
 }
+
+var lzOptions = {};

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LFCApplication.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LFCApplication.as  
2008-01-14 06:00:08 UTC (rev 7817)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LFCApplication.as  
2008-01-14 06:33:43 UTC (rev 7818)
@@ -61,5 +61,11 @@
 
 }
 
+// Resource library
+// contains {ptype, class, frames, width, height}
+// ptype is one of "ar" (app relative) or "sr" (system relative)
+var LzResourceLibrary = {};
 
 
+
+

Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as        
2008-01-14 06:00:08 UTC (rev 7817)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as        
2008-01-14 06:33:43 UTC (rev 7818)
@@ -105,14 +105,80 @@
       }
 
 
+      var skiponload = false;
+      var resourceWidth;
+      var resourceHeight;
+      var baseurl;
+      function  __preloadFrames () { }
+
       /** setResource( String:resource )
           o Displays a compiled-in resource (by name)
           o Calls setSource to load media if resource is an URL
           o Uses the resourceload callback method when the resource finishes 
loading 
       */
-      public function setResource (resource:String):void {
-      }
+public function setResource (r:String):void {
+    if (this.resource == r) return;
+    if ( r.indexOf('http:') == 0 || r.indexOf('https:') == 0){
+        this.skiponload = false;
+        this.setSource( r );
+        this.resource = r;
+        return;
+    }
 
+    this.resource = r;
+
+    // look up resource name in LzResourceLibrary
+    // LzResourceLibrary is in the format:
+    // 
LzResourceLibrary.lzscrollbar_xthumbleft_rsc={ptype:"ar"||"sr",frames:["lps/components/lz/resources/scrollbar/scrollthumb_x_lft.png"],width:1.0,height:12.0}
+
+    var res = LzResourceLibrary[r];
+    if (! res) {
+        if ($debug) {
+            Debug.warn('Could not find resource', r);
+        }
+        return;
+    }
+
+    // TODO [hqm 2008-01] How do we deal with multiframe embedded resources??
+    if ('assetclass' in res) {
+        var assetclass = res['assetclass'];
+        var asset:DisplayObject = new assetclass();
+        addChild(asset);
+        return;
+    }
+
+
+    var urls = res.frames;
+
+    //this.owner.onimload.sendEvent({width: res.width, height: res.height});
+    this.resourceWidth = res.width;
+    this.resourceHeight = res.height;
+    this.skiponload = true;
+
+    //Update the view's totalframes
+    this.owner.setTotalFrames (urls.length);
+
+    // It could be a multi-frame resource. Take first frame.
+    var url = urls[0];
+    if (url) {
+        this.baseurl = '';
+        if (res.ptype) {
+            if (res.ptype == 'sr') {
+                this.baseurl = lzOptions.ServerRoot + '/';
+            }
+            //Debug.write('ptype', res.ptype, this.baseurl);
+        }
+
+        this.frames = urls;
+        this.__preloadFrames();
+        this.setSource(url, true);
+    } else {
+        this.setSource(r, true);
+    }
+    //Debug.info('setResource ', r, this.frames)
+}
+
+
       public var imgLoader:Loader;
       private var IMGDEPTH:int = 0;
 

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as    
2008-01-14 06:00:08 UTC (rev 7817)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as    
2008-01-14 06:33:43 UTC (rev 7818)
@@ -57,26 +57,26 @@
         }
 
 
-        override public function setWidth( width:* ):void {
-            super.setWidth(width);
-            if (width) {
-                this.textfield.width = width;
+        override public function setWidth( w:* ):void {
+            super.setWidth(w);
+            if (w) {
+                this.textfield.width = w;
             }
         }
 
-        override public function setHeight( height:* ):void {
-            super.setHeight(height);
-            if (height) {
-                this.textfield.height = height;
+        override public function setHeight( h:* ):void {
+            super.setHeight(h);
+            if (h) {
+                this.textfield.height = h;
             }
         }
 
-        private function createTextField(x:Number, y:Number, width:Number, 
height:Number):TextField {
+        private function createTextField(nx:Number, ny:Number, w:Number, 
h:Number):TextField {
         var tfield:TextField = new TextField();
-            tfield.x = x;
-            tfield.y = y;
-            tfield.width = width;
-            tfield.height = height;
+            tfield.x = nx;
+            tfield.y = ny;
+            tfield.width = w;
+            tfield.height = h;
             tfield.border = false;
             //tfield.cacheAsBitmap = true;
             addChild(tfield);
@@ -130,6 +130,7 @@
                     //textclip.autoSize = TextFieldAutoSize.NONE;
                 }
             }  else {
+                // Does setting height of the text object do the right thing 
in swf9?
                 textclip.height = args.height;
             }
             // Default the scrollheight to the visible height.

Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LaszloView.js
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LaszloView.js    
2008-01-14 06:00:08 UTC (rev 7817)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LaszloView.js    
2008-01-14 06:33:43 UTC (rev 7818)
@@ -937,8 +937,33 @@
   * 
   * @param String resourceName: a string naming the id of the resource to 
attach
   */
-    function setResource ( resourceName, ignore = null )  { }
+    function setResource ( resourceName, ignore = null )  { 
+    if (resourceName == null || resourceName == this._resource) return;
+    /*if (LzLoader.__LZmonitorState) {
+        Debug.monitor(this, 'isloaded');
+        Debug.monitor(this, 'play');
+        Debug.monitor(this, 'playing');
+        Debug.monitor(this, '__LZtracking');
+        //Debug.monitor(this, '__lzcheckframe');
+    }
+    if ( resourceName.indexOf('http:') == 0 || resourceName.indexOf('https:') 
== 0 ){
+        this.setSource( resourceName );
+        return;
+    }
+    //Debug.write(this.sprite);
+    */
 
+    if (resourceName != 'empty') this.sprite.setResource(resourceName);
+    
+    this.__LZhaser = resourceName == "empty";
+
+    this.resource = resourceName;
+    if (this.onresource.ready) this.onresource.sendEvent( resourceName );
+
+    this._resource = this.resource;
+}
+
+
 /**
   * @access private
   * Called by sprites when the resource has been loaded to send the

Modified: 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
===================================================================
--- 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
 2008-01-14 06:00:08 UTC (rev 7817)
+++ 
openlaszlo/branches/devildog/WEB-INF/lps/server/src/org/openlaszlo/compiler/SWF9Writer.java
 2008-01-14 06:33:43 UTC (rev 7818)
@@ -196,8 +196,27 @@
         }
         mLogger.debug("relPath is: "+relPath);
 
-        StringBuffer sbuf = new StringBuffer("LzResourceLibrary." + 
-                                             name + "={ptype: \"" + pType + 
"\", frames:[");
+        StringBuffer sbuf = new StringBuffer();
+
+        //      [Embed(source="logo.swf")]
+        // public var logoClass:Class;
+      
+        sbuf.append("#passthrough {\n");
+        String rpath;
+        try {
+            rpath = inputFile.getCanonicalPath();
+            // Fix Winblows pathname backslash lossage
+            rpath = rpath.replaceAll("\\", "/");
+        } catch (IOException e) {
+            throw new ImportResourceError(inputFile.toString(), e, mEnv);
+        }
+        sbuf.append("[Embed(source=\""+rpath+"\")]\n");
+        String assetClassname = "__embed_lzasset_" + name;
+        sbuf.append("var "+assetClassname+":Class;\n");
+        sbuf.append("}#\n");
+
+        sbuf.append("LzResourceLibrary." + 
+                    name + "={ptype: \"" + pType + "\", assetclass: 
"+assetClassname +", frames:[");
         sbuf.append("'"+relPath+"'");
 
         Resource res =  (Resource)mResourceMap.get(inputFile.toString());
@@ -326,6 +345,9 @@
             addScript("__LzDebug.makeDebugWindow()");
         }
 
+
+        // Put the canvas sprite on the 'stage'.
+        addScript("addChild(canvas.sprite)");
         // Tell the canvas we're done loading.
         addScript("canvas.initDone()");
 


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to