Author: hqm
Date: 2008-01-13 19:45:57 -0800 (Sun, 13 Jan 2008)
New Revision: 7816

Modified:
   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/LzText.js
Log:
Change 20080113-hqm-6 by [EMAIL PROTECTED] on 2008-01-13 22:44:46 EST
    in /cygdrive/c/users/hqm/openlaszlo/devildog/WEB-INF/lps/lfc
    for http://svn.openlaszlo.org/openlaszlo/branches/devildog/WEB-INF/lps/lfc

Summary: fix clipping on text sprite

New Features:

Bugs Fixed:

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

Documentation:

Release Notes:

Details:
    
Have to be careful now; 'height' and 'width' are native properties of 
flash.display.Sprite,
which LzSprite is a subclass of. Have to make sure to change references to 
'lzwidth' and 'lzheight'
when copying code from swf8 kernel.



Tests:



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 02:20:02 UTC (rev 7815)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as        
2008-01-14 03:45:57 UTC (rev 7816)
@@ -25,8 +25,8 @@
 
       public var bgColor:* = null;
 
-      public var lzwidth:int = 0;
-      public var lzheight:int = 0;
+      public var lzwidth:* = 0;
+      public var lzheight:* = 0;
 
       public var opacity:Number = 1;
       public var playing:Boolean = false;
@@ -290,13 +290,21 @@
           o Sets the sprite to the specified width 
       */
       public function setWidth( v:* ):void {
-          //trace('sprite setWidth', v);
+          //trace('..sprite setWidth', v);
           this.lzwidth = v;
           // TODO [hqm 2008-01] We need to add back in the code here to
           // update the clipping mask size, and resource stretching as well, 
see swf8 kernel
           if (this.clickregion != null) {
               this.clickregion.scaleX = v;
           }
+
+          // Update the clip region if there is one
+          if (this.masksprite) {
+              //trace('...sprite setting mask w,h', this.lzwidth 
,this.lzheight);
+              this.masksprite.scaleX = this.lzwidth;
+              this.masksprite.scaleY = this.lzheight;
+          }
+
           draw();
       }
 
@@ -305,13 +313,20 @@
           o Sets the sprite to the specified height 
       */
       public function setHeight( v:* ):void {
-          //trace('sprite setHeight', v);
+          //trace('..sprite setHeight', v);
           this.lzheight = v;
           // TODO [hqm 2008-01] We need to add back in the code here to
           // update the clipping mask size, and resource stretching as well, 
see swf8 kernel
           if (this.clickregion != null) {
               this.clickregion.scaleY = v;
           }
+
+          // Update the clip region if there is one
+          if (this.masksprite) {
+              //trace('...sprite setting mask w,h', this.lzwidth 
,this.lzheight);
+              this.masksprite.scaleX = this.lzwidth;
+              this.masksprite.scaleY = this.lzheight;
+          }
           draw();
       }
 
@@ -396,19 +411,30 @@
           var ms:Sprite = this.masksprite;
           if (ms == null) {
               ms = new Sprite();
+              ms.graphics.clear();
+              ms.graphics.beginFill(0xffffff);
+              ms.graphics.drawRect(0, 0, 1, 1);
+              ms.graphics.endFill();
+              ms.scaleX = this.lzwidth;
+              ms.scaleY = this.lzheight;
+              addChild(ms);
+              this.mask = ms;
+              this.masksprite = ms;
+              trace('applyMask [1] ', this.lzwidth, this.lzheight, owner);
+          } else {
+              if (this.mask == null) {
+                  addChild(ms);
+                  this.mask = ms;
+              }
+              trace('applyMask [2] ', this.lzwidth, this.lzheight, owner);
+              ms.scaleX = this.lzwidth;
+              ms.scaleY = this.lzheight;
           }
-          ms.graphics.clear();
-          ms.graphics.beginFill(0xffffff);
-          ms.graphics.drawRect(this.x, this.y, this.lzwidth, this.lzheight);
-          ms.graphics.endFill();
-          addChild(ms);
-          this.mask = this.masksprite;
       }
 
       public function removeMask():void {
+          this.removeChild(this.masksprite);
           this.mask = null;
-          this.removeChild(this.masksprite);
-          this.masksprite == null;
       }
 
 

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 02:20:02 UTC (rev 7815)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as    
2008-01-14 03:45:57 UTC (rev 7816)
@@ -40,7 +40,7 @@
         public var colorstring:String = "#000000";
         public var text:String = "";
 
-        public var resize:Boolean = false;
+        public var resize:Boolean = true;
         public var multiline:Boolean = false;
         public var underline:Boolean = false;
         public var closeformat:String;
@@ -112,6 +112,8 @@
             //(args.width == null && typeof(args.$refs.width) != "function")
 
 
+            textclip.autoSize = TextFieldAutoSize.LEFT;
+
             // To compute our height:
             // + If height is supplied, use it.
             // + if no height supplied:
@@ -120,13 +122,8 @@
             // 
             if (args.height == null && (args.$ref == null || 
typeof(args.$refs.height) != "function")) {
                 this.sizeToHeight = true;
+                //trace('sizeToHeight == true');
                 // set autoSize to get text measured
-                textclip.autoSize = TextFieldAutoSize.LEFT;
-                textclip.htmlText = this.format + "__ypgSAMPLE__" + 
this.closeformat;
-
-                this.height = textclip.height;
-
-                textclip.htmlText = this.format + this.text + this.closeformat;
                 if (!this.multiline) {
                     // But turn off autosizing for single line text, now that
                     // we got a correct line height from flash.
@@ -134,7 +131,6 @@
                 }
             }  else {
                 textclip.height = args.height;
-                //this.setHeight(args.height);
             }
             // Default the scrollheight to the visible height.
             this.scrollheight = this.height;
@@ -143,11 +139,11 @@
             // __setFormat during instantiation of an lzText. Figure
             // out how to suppress the other calls from setters.
             this.__setFormat();
-
+            this.setText(args.text);
         }
 
         override public function setBGColor( c:* ):void {
-            trace("LzTextSprite. setBGColor  ", c);
+            //trace("LzTextSprite. setBGColor  ", c);
             if (c == null) {
                 this.textfield.background = false; }
             else {
@@ -228,23 +224,17 @@
                 t = t.toString();
             }
 
-            // If accessibility is enabled, hunt for <img alt="...."> tags and 
assign and
-            // put the alt tag somewhere a screen reader can find it.
-            /*
-              if (canvas.accessible) {
-              t = this.annotateAAimg(t);
-              }
-            */
-
             this.text =  t;// this.format + t + this.closeformat if proper 
measurement were working
             this.textfield.htmlText = this.format + t + this.closeformat;
-            trace('setting textfield.htmlText', this.textfield.htmlText);
+            //trace('setting textfield.htmlText', this.textfield.htmlText);
         
             if (this.resize && (this.multiline == false)) {
                 // single line resizable fields adjust their width to match 
the text
             var w:Number = this.getTextWidth();
-                // only set width if it changed
-                if (w != this.width) this.setWidth(w);
+                //trace('lztextsprite resize setwidth ', w, this.lzheight );
+                if (w != this.lzwidth) {
+                    this.setWidth(w);
+                }
             }
 
             //multiline resizable fields adjust their height
@@ -252,12 +242,6 @@
                 this.setHeight(this.textfield.height);
             }
 
-            /*
-              if (this.multiline && this.scroll == 0 ) {
-              var scrolldel = new LzDelegate(this, "__LZforceScrollAttrs");
-              LzIdle.callOnIdle(scrolldel);
-              }
-            */
             //this.textfield.cacheAsBitmap = true;
         }
 

Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LzText.js
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LzText.js        
2008-01-14 02:20:02 UTC (rev 7815)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/views/LzText.js        
2008-01-14 03:45:57 UTC (rev 7816)
@@ -425,15 +425,8 @@
 setters.pattern = "setPattern";
 
 
-    // ++++ TODO [hqm 2008-01] make this true again when I figure out
-    // why clipping is messing up for text sprite
-    //defaultattrs.clip = true;
-defaultattrs.clip = false;
+defaultattrs.clip = true;
 
-
-
-
-
 /**
   * setResize set behavior of text field width when new text is added.
   * LzText only (cannot be used with LzInputText).


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

Reply via email to