[Laszlo-checkins] r9442 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9

bargull@openlaszlo.org bargull at openlaszlo.org
Tue Jun 3 06:02:22 PDT 2008


Author: bargull
Date: 2008-06-03 06:02:19 -0700 (Tue, 03 Jun 2008)
New Revision: 9442

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
Log:
Change 20080602-bargull-VpJ by bargull at dell--p4--2-53 on 2008-06-02 22:33:35
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: further weather demo progress

New Features:

Bugs Fixed: LPP-6090

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

Documentation:

Release Notes:

Details:
- stretched images show up properly
- added measuring text-height (needs to be tested for multiline-text, though)

   

Tests:
run weather demo in swf9: 
- images show up in 2nd and 3rd tabelement
- text looks better in 1st tabelement



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-06-03 12:59:44 UTC (rev 9441)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as	2008-06-03 13:02:19 UTC (rev 9442)
@@ -217,6 +217,8 @@
       var info:LoaderInfo = LoaderInfo(loader.contentLoaderInfo);
           if (event.type == Event.COMPLETE) {
               this.resourceLoaded = true;
+              this.resourcewidth = loader.width;
+              this.resourceheight = loader.height;
               // Apply stretch if needed, now that we know the asset dimensions.
               this.applyStretchResource();
               if (this.owner != null) {

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as	2008-06-03 12:59:44 UTC (rev 9441)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as	2008-06-03 13:02:19 UTC (rev 9442)
@@ -131,18 +131,13 @@
             //    if  single line, use font line height
             //    else get height from flash textobject.textHeight 
             // 
-            if (args.height == null && (args.$ref == null || typeof(args.$refs.height) != "function")) {
+            if (args['height'] == null) {
                 this.sizeToHeight = true;
-                //trace('sizeToHeight == true');
-                // set autoSize to get text measured
-                if (!this.multiline) {
-                    // But turn off autosizing for single line text, now that
-                    // we got a correct line height from flash.
-                    //textclip.autoSize = TextFieldAutoSize.NONE;
-                }
             }  else {
                 // Does setting height of the text object do the right thing in swf9?
-                textclip.height = args.height;
+                if (!(args.height is LzInitExpr)) {
+                    textclip.height = args.height;
+                }
             }
             // Default the scrollheight to the visible height.
             this.scrollheight = this.height;
@@ -152,6 +147,16 @@
             // out how to suppress the other calls from setters.
             this.__setFormat();
             this.setText(args.text);
+            
+            if (this.sizeToHeight) {
+                //text and format is set, measure it
+                var lm:TextLineMetrics = textclip.getLineMetrics(0);
+                var h = lm.ascent + lm.descent + lm.leading;
+                //TODO [anba 20080602] is this ok for multiline? 
+                if (this.multiline) h *= textclip.numLines;
+                h += 4;//2*2px gutter, see flash docs for flash.text.TextLineMetrics 
+                this.setHeight(h);
+            }
         }
 
         override public function setBGColor( c:* ):void {
@@ -268,7 +273,19 @@
 
             //multiline resizable fields adjust their height
             if (this.sizeToHeight) {
-                this.setHeight(Math.max(this.textfield.textHeight, this.textfield.height));
+                if (this.multiline) {
+                    //FIXME [20080602 anba] won't possibly work, example: 
+                    //textfield.textHeight=100
+                    //textfield.height=10
+                    //=> setHeight(Math.max(100, 10)) == setHeight(100)
+                    //setHeight sets textfield.height to 100
+                    //next round:
+                    //textfield.textHeight=10 (new text was entered)
+                    //textfield.height=100 (set above!)
+                    //=> setHeight(Math.max(10, 100)) == setHeight(100)
+                    // => textfield.height still 100, sprite-height didn't change, but it should!
+                    this.setHeight(Math.max(this.textfield.textHeight, this.textfield.height));
+                }
             }
             //this.textfield.cacheAsBitmap = true;
         }



More information about the Laszlo-checkins mailing list