Author: hqm
Date: 2007-12-06 07:32:35 -0800 (Thu, 06 Dec 2007)
New Revision: 7466
Added:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/TestText.as
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/kernel/swf9/TestApp.as
Log:
checkpoint sprites text
Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
2007-12-06 13:31:35 UTC (rev 7465)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzSprite.as
2007-12-06 15:32:35 UTC (rev 7466)
@@ -35,7 +35,6 @@
public var frames:uint = 1;
public var resource:String = null;
public var source:String = null;
- public var text:String = null;
public var clip:Boolean = false;
public var stretches:String = null;
public var resourcewidth:Number = 0;
@@ -260,7 +259,7 @@
o Sets the foreground color of the sprite
o Can be a number (0xff00ff):void or a string ('#ff00ff'):void
*/
- public function setColor( color:Object ):void {
+ public function setColor( color:* ):void {
}
Modified:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
2007-12-06 13:31:35 UTC (rev 7465)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/LzTextSprite.as
2007-12-06 15:32:35 UTC (rev 7466)
@@ -13,15 +13,15 @@
package {
import flash.display.*;
import flash.events.*;
- import mx.controls.Button;
+ import flash.text.*;
import flash.net.URLRequest;
public class LzTextSprite extends LzSprite {
- public var textfield:TextField;
+ public var textfield:TextField = null;
- static var PAD_TEXTWIDTH:uint = 4;
+ public static var PAD_TEXTWIDTH:uint = 4;
public var fontsize:String = "11";
@@ -33,12 +33,15 @@
public var resize:Boolean = false;
public var multiline:Boolean = false;
-
+ public var underline:Boolean = false;
public var closeformat:String;
public var format:String;
+ public var sizeToHeight:Boolean = false;
+ public var password:Boolean = false;
+ public var scrollheight:Number = 0;
- public function LztextSprite (... initargs) {
+ public function LzTextSprite (... initargs) {
// owner:*, isroot:Boolean
this.textfield = createTextField(0,0,100,20);
}
@@ -55,6 +58,64 @@
return tfield;
}
+ public function __initTextProperties (args:Object):void {
+ this.password = args.password ? true : false;
+ var textclip:TextField = this.textfield;
+ textclip.displayAsPassword = this.password;
+
+ textclip.selectable = args.selectable;
+ textclip.autoSize = TextFieldAutoSize.NONE;
+
+ this.setMultiline( args.multiline );
+
+ //inherited attributes, documented in view
+ this.fontname = args.font;
+ this.fontsize = args.fontsize;
+ this.fontstyle = args.fontstyle;
+ this.__setFormat();
+
+ textclip.htmlText = this.format + this.text + this.closeformat;
+ textclip.background = false;
+
+ // To compute our width:
+ // + if text is multiline:
+ // if no width is supplied, use parent width
+ // + if text is single line:
+ // if no width was supplied and there's no constraint, measure
the text width:
+ // if empty text content was supplied, use DEFAULT_WIDTH
+
+
+ //(args.width == null && typeof(args.$refs.width) != "function")
+
+
+ // To compute our height:
+ // + If height is supplied, use it.
+ // + if no height supplied:
+ // 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")) {
+ this.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.
+ textclip.autoSize = TextFieldAutoSize.NONE;
+ }
+ } else {
+ textclip.height = args.height;
+ //this.setHeight(args.height);
+ }
+ // Default the scrollheight to the visible height.
+ this.scrollheight = this.height;
+ }
+
public function setBorder ( onroff:Boolean):void {
this.textfield.border = (onroff == true);
}
@@ -98,7 +159,7 @@
* Sets the color of all the text in the field to the given hex color.
* @param Number c: The color for the text -- from 0x0 (black) to
0xFFFFFF (white)
*/
- public function setColor ( col:* ):void {
+ public override function setColor ( col:* ):void {
this.colorstring = "#" + col.toString( 16 );
this.__setFormat();
this.setText( this.text );
@@ -139,7 +200,7 @@
if (this.resize && (this.multiline == false)) {
// single line resizable fields adjust their width to match the
text
- var w = this.getTextWidth();
+ var w:Number = this.getTextWidth();
// only set width if it changed
if (w != this.width) this.setWidth(w);
}
@@ -193,11 +254,11 @@
if (this.multiline) {
this.textfield.multiline = true;
this.textfield.wordWrap = true;
- //this.textfield.autoSize = true;
+
} else {
this.textfield.multiline = false;
this.textfield.wordWrap = false;
- //this.textfield.autoSize = false;
+
}
}
@@ -209,19 +270,19 @@
this.textfield.selectable = isSel;
}
- public function getTextWidth ( ):void {
- var mc = this.textfield;
- var ml = mc.multiline;
- var mw = mc.wordWrap;
- mc.multiline = false;
- mc.wordWrap = false;
- var twidth = (mc.textWidth == 0) ? 0 : mc.textWidth +
LzTextSprite.PAD_TEXTWIDTH;
- mc.multiline = ml;
- mc.wordWrap = mw;
+ public function getTextWidth ( ):Number {
+ var tf:TextField = this.textfield;
+ var ml:Boolean = tf.multiline;
+ var mw:Boolean = tf.wordWrap;
+ tf.multiline = false;
+ tf.wordWrap = false;
+ var twidth:Number = (tf.textWidth == 0) ? 0 : tf.textWidth +
LzTextSprite.PAD_TEXTWIDTH;
+ tf.multiline = ml;
+ tf.wordWrap = mw;
return twidth;
}
- public function getTextHeight ( ):void {
+ public function getTextHeight ( ):Number {
return this.textfield.textHeight;
}
Modified: openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/TestApp.as
===================================================================
--- openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/TestApp.as
2007-12-06 13:31:35 UTC (rev 7465)
+++ openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/TestApp.as
2007-12-06 15:32:35 UTC (rev 7466)
@@ -18,8 +18,8 @@
public class TestApp extends Sprite {
public function TestApp () {
- /*
+
//stage.addEventListener(MouseEvent.CLICK, clickListener);
var sprite1:* = new LzSprite(null, false);
@@ -81,15 +81,15 @@
sprite5.addEventListener(MouseEvent.MOUSE_DOWN, describeSprite) ;
-*/
+
// Test 'stretches'
var sprite6:LzSprite = new LzSprite(null, false);
sprite6.owner = this;
- sprite6.setX(0);
- sprite6.setY(0);
+ sprite6.setX(400);
+ sprite6.setY(200);
sprite6.setWidth(100);
sprite6.setHeight(50);
sprite6.stretchResource("both");
@@ -101,8 +101,8 @@
var sprite7:LzSprite = new LzSprite(null, false);
sprite7.owner = this;
- sprite7.setX(0);
- sprite7.setY(0);
+ sprite7.setX(400);
+ sprite7.setY(200);
sprite7.setWidth(100);
sprite7.setHeight(100);
sprite7.setSource("logo.swf");
Added: openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/TestText.as
Property changes on:
openlaszlo/branches/devildog/WEB-INF/lps/lfc/kernel/swf9/TestText.as
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins