LTextField Class
创建新的 LTextField 实例。在创建 LTextField 实例后,调用父 LSprite 对象的 addChild() 或 addChildAt() 方法可将 LTextField 实例添加到显示列表中。 LTextField 类的方法允许您设置、选择并操作在创作过程中或运行时创建的动态或输入文本字段中的文本。
Constructor
LTextField
()
public
Example:
var theTextField = new LTextField();
theTextField.setType(LTextFieldType.INPUT);
theTextField.x = 10;
theTextField.y = 10;
addChild(theTextField);
Item Index
Methods
Properties
Methods
addEventListener
-
type
-
listener
使用 LEventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。可以为特定类型的事件、阶段和优先级在显示列表中的所有节点上注册事件侦听器。
成功注册一个事件侦听器后,无法通过额外调用 addEventListener() 来更改其优先级。要更改侦听器的优先级,必须首先调用 removeListener()。然后,可以使用新的优先级再次注册该侦听器。
如果不再需要某个事件侦听器,可调用 removeEventListener() 删除它,否则会产生内存问题。
Parameters:
-
type
String事件的类型。
-
listener
Function处理事件的侦听器函数。
cacheAsBitmap
-
value
如果设置为 true,则运行时将缓存显示对象的内部位图表示形式。此缓存可以提高包含复杂矢量内容的显示对象的性能。速度可能会大大加快,具体取决于矢量内容的复杂性。
*动态改变的对象无法使用cacheAsBitmap
Parameters:
-
value
Bool分配给触摸点的整数(触摸设备)。
Example:
var layer = new LSprite();
layer.x = layer.y = 100;
addChild(layer);
var bitmapdata = new LBitmapData(event.target);
var bitmap = new LBitmap(bitmapdata);
layer.addChild(bitmap);
bitmap = new LBitmap(bitmapdata);
bitmap.x = bitmap.y = 50;
layer.addChild(bitmap);
var sprite = new LSprite();
sprite.graphics.drawRect(3, "#000000", [0, 0, 190, 100],true,"#00FF00");
sprite.x = -100;
layer.addChild(sprite);
layer.cacheAsBitmap(true);
callParent
-
functionName
-
arguments
调用父类的函数。
Parameters:
-
functionName
String函数名
-
arguments
Array固定值arguments
Example:
function funA(){
LExtends(this,LObject,[]);
}
funA.prototype.myName = function(){
return "AAA";
}
function funB(){
LExtends(this,funA,[]);
}
funB.prototype.myName = function(){
return "BBB";
}
function funC(){
LExtends(this,funA,[]);
}
funC.prototype.myName = function(){
return this.callParent("myName",arguments);
}
LInit(1000/50,"legend",800,150,main);
function main(){
LGlobal.setDebug(true);
var objB = new funB();
trace(objB.myName());//BBB
var objC = new funC();
trace(objC.myName());//AAA
}
clone
()
LTextField
public
返回一个LTextField的克隆对象。
Returns:
一个新的 LTextField 对象,它与原始对象相同.
Example:
var theTextField = new LTextField();
theTextField.text = "font test";
addChild(theTextField);
var theTextField2 = theTextField.clone();
theTextField2.y = 50;
addChild(theTextField2);
die
()
public
清空所使用的内存。
dispatchEvent
-
event
将事件调度到事件流中。事件目标是对其调用 dispatchEvent() 方法的 LEventDispatcher 对象。
Parameters:
-
event
LEvent | String调度到事件流中的 Event 对象。如果正在重新调度事件,则会自动创建此事件的一个克隆。在调度了事件后,其 target 属性将无法更改,因此您必须创建此事件的一个新副本以能够重新调度。
Returns:
如果成功调度了事件,则值为 true。
Example:
function MyEventObject(){
var self = this;
LExtends(self,LSprite,[]);
self.graphics.drawRect(1,"#000000",[0,0,100,100],true,"#000000");
self.graphics.drawRect(1,"#FF0000",[100,0,100,100],true,"#FF0000");
self.addEventListener(LMouseEvent.MOUSE_UP,self.onclick);
self.addEventListener(MyEventObject.CLICK_LEFT,function(event){
trace("dispatchEvent");
});
self.addEventListener(MyEventObject.CLICK_RIGHT,function(event){
trace("dispatchEvent event.name = " + event.name);
});
}
MyEventObject.CLICK_LEFT = "click_left";
MyEventObject.CLICK_RIGHT = "click_right";
MyEventObject.prototype.onclick = function(event){
var self = event.clickTarget;
if(event.selfX < 100){
self.dispatchEvent(MyEventObject.CLICK_LEFT);
}else{
var event = new LEvent(MyEventObject.CLICK_RIGHT);
event.name = "LEvent Test";
self.dispatchEvent(event);
}
}
focus
()
public
获取焦点。
Example:
var theTextField = new LTextField();
theTextField.x = 20;
theTextField.y = 20;
theTextField.text = "Click the Enter Key, please!";
addChild(theTextField);
var theTextField1 = new LTextField();
theTextField1.x = 20;
theTextField1.y = 100;
theTextField1.setType(LTextFieldType.INPUT);
addChild(theTextField1);
theTextField1.addEventListener(LTextEvent.TEXT_INPUT, function (e) {
if(e.keyCode == 13){
theTextField2.focus();
}
});
var theTextField2 = new LTextField();
theTextField2.x = 20;
theTextField2.y = 140;
theTextField2.setType(LTextFieldType.INPUT);
addChild(theTextField2);
theTextField2.addEventListener(LTextEvent.TEXT_INPUT, function (e) {
if(e.keyCode == 13){
theTextField1.focus();
}
});
setTimeout(function () {
theTextField1.focus();
}, 200);
getBounds
-
targetCoordinateSpace
返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。
Parameters:
-
targetCoordinateSpace
LDisplayObject定义要使用的坐标系的显示对象。
Returns:
定义与 targetCoordinateSpace 对象坐标系统相关的显示对象面积的矩形。
getDataURL
-
type
-
ratio
将该对象转换成base64编码的image字符串。
Parameters:
-
type
String参数type在image/png,image/jpeg,image/svg+xml等 MIME类型中选择(可以不填,默认是image/png)。
-
ratio
Float如果是type = “image/jpeg”,可以有第二个参数,如果第二个参数ratio的值在0-1之间,则表示JPEG的质量等级,否则使用浏览器内置默认质量等级。
Returns:
base64编码的image字符串。
getHeight
()
Float
public
获取显示对象的高度,以像素为单位。
Returns:
显示对象的高度。
Example:
var theTextField = new LTextField();
theTextField.text = "getHeight test";
addChild(theTextField);
trace(theTextField.getHeight());
getParentByConstructor
-
constructor
通过构造函数向上查找对象。
Parameters:
-
constructor
Constructor某个构造函数
Returns:
查找到的对象。
Example:
function MyClass1(){
base(self,LSprite,[]);
}
function MyClass2(){
base(self,LSprite,[]);
}
var obj1 = new MyClass1();
var obj2 = new MyClass2();
var obj3 = new LSprite();
addChild(obj1);
obj1.addChild(obj2);
obj2.addChild(obj3);
trace(obj1.objectIndex == obj3.getParentByConstructor(MyClass1).objectIndex);//out: true
trace(obj2.objectIndex == obj3.getParentByConstructor(MyClass2).objectIndex);//out: true
getWidth
()
Float
public
获取显示对象的宽度,以像素为单位。
Returns:
显示对象的宽度。
Example:
var theTextField = new LTextField();
theTextField.text = "getWidth test";
addChild(theTextField);
trace(theTextField.getWidth());
globalToLocal
-
point
将 point 对象从舞台(全局)坐标转换为显示对象的(本地)坐标。
要使用此方法,请先创建 LPoint 类的一个实例。您分配的 x 和 y 值表示全局坐标,因为它们是相对于主显示区域的原点 (0,0) 的。然后将 LPoint 实例作为参数传递给 globalToLocal() 方法。该方法会返回一个新的 LPoint 对象,该对象具有相对于显示对象原点(而不是舞台原点)的 x 和 y 值。
Parameters:
-
point
LPoint用 LPoint 类创建的对象。 该 LPoint 对象指定 x 和 y 坐标作为属性。
Returns:
具有相对于显示对象的坐标的 LPoint 对象。
Example:
LInit(50, "legend", 800, 480, main);
function main () {
LGlobal.setDebug(true);
var circle = new LSprite();
circle.x = 10;
addChild(circle);
var point1 = new LPoint(0, 0);
trace(circle.globalToLocal(point1)); // [x=-10, y=0]
var point2 = new LPoint(10, 1);
trace(circle.globalToLocal(point2)); // [x=0, y=1]
var point3 = new LPoint(30, 20);
trace(circle.globalToLocal(point3)); // [x=20, y=20]
}
hasEventListener
-
type
检查 LEventDispatcher 对象是否为特定事件类型注册了任何侦听器。这样,您就可以确定 LEventDispatcher 对象在事件流层次结构中的哪个位置改变了对事件类型的处理。
Parameters:
-
type
String事件的类型。
Returns:
如果指定类型的侦听器已注册,则值为 true;否则,值为 false。
localToGlobal
-
point
将 point 对象从显示对象的(本地)坐标转换为舞台(全局)坐标。
此方法允许您将任何给定的 x 和 y 坐标从相对于特定显示对象原点 (0,0) 的值(本地坐标)转换为相对于舞台原点的值(全局坐标)。
要使用此方法,请先创建 Point 类的一个实例。您分配的 x 和 y 的值表示本地坐标,因为它们是相对于显示对象原点的值。
然后,您可以将创建的 Point 实例作为参数传递给 localToGlobal() 方法。该方法会返回一个新的 Point 对象,该对象具有相对于舞台原点(而不是显示对象原点)的 x 和 y 值。
Parameters:
-
point
LPoint使用 Point 类创建的点的名称或标识符,指定 x 和 y 坐标作为属性。
Returns:
具有相对于舞台的坐标的 Point 对象。
Example:
LInit(50, "legend", 800, 480, main);
var square;
function main () {
LGlobal.setDebug(true);
square = new LSprite();
square.graphics.drawRect(1,"#000000",[0, 0, 100, 100]);
square.x = 100;
square.y = 200;
addChild(square);
square.addEventListener(LMouseEvent.MOUSE_DOWN, traceCoordinates);
}
function traceCoordinates(event) {
var clickPoint = new LPoint(mouseX, mouseY);
trace("display object coordinates:", clickPoint);
trace("stage coordinates:", square.localToGlobal(clickPoint));
}
remove
()
public
将对象自己从父容器中移除。
removeAllEventListener
()
public
从 LEventDispatcher 对象中删除所有侦听器。
removeEventListener
-
type
-
listener
从 LEventDispatcher 对象中删除侦听器。如果没有向 LEventDispatcher 对象注册任何匹配的侦听器,则对此方法的调用没有任何效果。
Parameters:
-
type
String事件的类型。
-
listener
Function要删除的侦听器对象。
setMultiline
-
value
-
height
设置字段是否为多行文本字段。如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 LTextFieldType.INPUT 的字段中,将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。
Parameters:
-
value
Boolean表示字段是否为多行文本字段.
-
height
Int指定一行文本的高度.
Example:
var inputLayer = new LSprite();
inputLayer.graphics.drawRect(1,"#000000",[0, 0, 400, 150]);
var theTextField = new LTextField();
theTextField.setType(LTextFieldType.INPUT,inputLayer);
theTextField.setMultiline(true);
addChild(theTextField);
setType
-
type
-
obj
文本字段的类型。以下 LTextFieldType 常量中的任一个:LTextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 LTextFieldType.INPUT(指定用户可以编辑的输入文本字段)。默认值为 dynamic。
Parameters:
-
type
String文本字段的类型。
-
obj
LSprite文本框形状.
Example:
var inputLayer = new LSprite();
inputLayer.graphics.drawRect(1,"#000000",[0, 0, 400, 30]);
var theTextField = new LTextField();
theTextField.setType(LTextFieldType.INPUT,inputLayer);
addChild(theTextField);
setWordWrap
-
value
-
height
表示文本字段是否自动换行。如果设置的值为 true,则该文本字段自动换行;如果值为 false,则该文本字段不自动换行。默认值为 false。
Parameters:
-
value
Boolean表示文本字段是否自动换行.
-
height
Int指定一行文本的高度.
Example:
var theTextField = new LTextField();
theTextField.setWordWrap(true);
theTextField.width = 200;
theTextField.text = "text\ntext\ntexttexttexttexttexttexttexttexttexttexttexttexttexttext";
addChild(theTextField);
updateInput
()
public
当LTextField对象设置为输入框的时候,将LTextField对象的text值反映到输入框中。
Example:
var theTextField = new LTextField();
theTextField.x = 20;
theTextField.y = 20;
theTextField.text = "Click Enter Key to clear the text!";
addChild(theTextField);
var theTextField1 = new LTextField();
theTextField1.text = "test";
theTextField1.x = 20;
theTextField1.y = 100;
theTextField1.setType(LTextFieldType.INPUT);
addChild(theTextField1);
theTextField1.addEventListener(LTextEvent.TEXT_INPUT, function (e) {
if(e.keyCode == 13){
e.currentTarget.text = "";
e.currentTarget.updateInput();
e.preventDefault();
}
});
setTimeout(function () {
theTextField1.focus();
}, 200);
wind
()
public
文本逐字显示(打字机效果)。
Example:
LInit(50, "legend", 800, 480, main);
function main () {
var theTextField = new LTextField();
theTextField.text = "wait click";
theTextField.x = 10;
theTextField.y = 10;
theTextField.size = 20;
addChild(theTextField);
var button = new LButtonSample1("wind test start");
button.textField = theTextField;
button.x = 10;
button.y = 100;
addChild(button);
button.addEventListener(LMouseEvent.MOUSE_DOWN, onclick);
}
function windOver(event){
var theTextField = event.target;
theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
theTextField.text = "wind over";
}
function onclick(event){
var theTextField = event.currentTarget.textField;
if (theTextField.hasEventListener(LTextEvent.WIND_COMPLETE)) {
theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
}
theTextField.text = "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT";
theTextField.speed = 3;
theTextField.wind();
theTextField.addEventListener(LTextEvent.WIND_COMPLETE, windOver);
}
Properties
alpha
Float
public
表示指定对象的 Alpha 透明度值。有效值为 0(完全透明)到 1(完全不透明)。默认值为 1。alpha 设置为 0 的显示对象是活动的,即使它们不可见。
Default: 1
blendMode
String
public
LBlendMode 类中的一个值,用于指定要使用的混合模式。 内部绘制位图的方法有两种。 如果启用了混合模式或外部剪辑遮罩,则将通过向矢量渲染器添加有位图填充的正方形来绘制位图。 如果尝试将此属性设置为无效值,运行时会将此值设置为 LBlendMode.NORMAL。
Default: null
color
String
public
表示文本的颜色。
Default: "#000000"
Example:
var theTextField = new LTextField();
theTextField.text = "color test";
theTextField.x = 10;
theTextField.y = 10;
theTextField.color = "#FF0000";
addChild(theTextField);
displayAsPassword
Boolean
public
指定文本字段是否是密码文本字段。如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。
Default: false
Example:
var theTextField = new LTextField();
theTextField.setType(LTextFieldType.INPUT);
theTextField.x = 10;
theTextField.y = 10;
theTextField.displayAsPassword = true;
addChild(theTextField);
filters
Array
public
包含当前与显示对象关联的每个滤镜对象的索引数组。
Default: null
font
String
public
使用此文本格式的文本的字体名称,以字符串形式表示。
Default: Arial
Example:
var theTextField = new LTextField();
theTextField.text = "font test";
theTextField.x = 10;
theTextField.y = 10;
theTextField.font = "Georgia";
addChild(theTextField);
heightMode
Float
public
获取文字高度的时候,是否以[gjpqy]为标准。
可以设定的值有下面两种:
LTextField.HEIGHT_MODE_BOTTOM:获取文字高度时,不考虑[gjpqy]的下半部。
LTextField.HEIGHT_MODE_BASELINE:获取文字高度时,考虑[gjpqy]的下半部。
也就是说使用LTextField.HEIGHT_MODE_BASELINE获取高度,比LTextField.HEIGHT_MODE_BOTTOM要略大。
注意:HTML5中没有直接获取文字高度的方法,所以这两种方式无论使用哪一种获取的高度都无法绝对准确。
Default: LTextField.HEIGHT_MODE_BOTTOM
htmlText
String
public
包含文本字段内容的 HTML 表示形式。 目前支持以下 HTML 标签:
标签 | 说明 |
---|---|
粗体标签 | <b> 标签以粗体形式呈现文本。粗体必须可用于所使用的字体。 |
字体标签 | <font> 标签指定一种字体或一个字体列表来显示文本。字体标签支持以下属性:
・color:字体的颜色。 ・face:指定要使用的字体的名称。 ・size:指定字体的大小。 |
斜体标签 | <i> 标签以斜体形式显示标签中的文本。斜体必须可用于所使用的字体。 |
段落标签 | <p> 标签创建一个新段落。必须将文本字段设置为多行文本字段才能使用此标签。 |
span 标签 | <span> 标签只可用于 CSS 文本样式。它支持以下属性: ・class:指定 LStyleSheet 对象定义的 CSS 样式类。 |
下划线标签 | <u> 标签为标签文本添加下划线。 |
Example:
var theTextField = new LTextField();
theTextField.setWordWrap(true,30);
theTextField.htmlText = "ABC<font face='Book Antiqua' color=\"#FF0000\" size='20'>A<p>B</p>C<font color='#008800' size='24'><i>ABC</i><font size='15'>ABC</font></font>ABC</font>ABC<b>ABC</b><u>ABC</u>";
theTextField.x = 10;
theTextField.y = 100;
theTextField.textBaseline = "alphabetic";
addChild(theTextField);
lineColor
String
public
文字描边效果的线的颜色。
Default: "#000000"
lineWidth
Int
public
文字描边效果的线宽。
Default: 1
mask
LDisplayObject
public
调用显示对象被指定的 mask 对象遮罩。要确保当舞台缩放时蒙版仍然有效,mask 显示对象必须处于显示列表的活动部分。但不绘制 mask 对象本身。将 mask 设置为 null 可删除蒙版。
Default: null
Example:
function main () {
var loader = new LLoader();
loader.addEventListener(LEvent.COMPLETE, loadBitmapdata);
loader.load("face.png", "bitmapData");
}
function loadBitmapdata (event) {
var bitmapdata = new LBitmapData(event.target);
var bitmap = new LBitmap(bitmapdata);
addChild(bitmap);
var maskObj = new LSprite();
maskObj.graphics.drawRect(0, "#ff0000", [10, 10, 150, 100]);
bitmap.mask = maskObj;
}
mouseEnabled
Boolean
public
指定此对象是否接收鼠标或其他用户输入、消息。默认值为 true,这表示默认情况下,显示列表上的任何 LInteractiveObject 实例都会接收鼠标事件或其他用户输入事件。如果将 mouseEnabled 设置为 false,则实例将不接收任何鼠标事件(或其他用户输入事件,例如键盘事件)。显示列表上的该实例的任何子级都不会受到影响。要更改显示列表上对象的所有子级的 mouseEnabled 行为,请使用 LDisplayObjectContainer.mouseChildren。
Example:
LGlobal.setDebug(true);
var button01 = new LButtonSample1("mouseEnabled=true");
button01.x = button01.y = 20;
addChild(button01);
button01.addEventListener(LMouseEvent.MOUSE_DOWN,function(e){
trace("button01 click");
});
var button02 = new LButtonSample1("mouseEnabled=false");
button02.x = 20;
button02.y = 150;
button02.mouseEnabled = false;
addChild(button02);
button02.addEventListener(LMouseEvent.MOUSE_DOWN,function(e){
trace("button02 click");
});
numLines
Int
public
[只读]定义多行文本字段中的文本行数。如果 setWordWrap(true),则在文本自动换行时会增加行数。
objectIndex
Int
public
对象的ID
parent
LDisplayObjectContainer
public
[只读] 表示包含此显示对象的 DisplayObjectContainer 对象。
使用 parent 属性可以指定高于显示列表层次结构中当前显示对象的显示对象的相对路径。
可以使用 parent 在显示列表中上移多个级别,如下所示:
this.parent.parent.x = 20;
Example:
var sprite1 = new LSprite();
sprite1.name = "sprite1";
var sprite2 = new LSprite();
sprite2.name = "sprite2";
var sprite3 = new LSprite();
sprite3.name = "sprite3";
sprite1.addChild(sprite2);
sprite2.addChild(sprite3);
trace(sprite2.parent.name); // sprite1
trace(sprite3.parent.name); // sprite2
trace(sprite3.parent.parent.name); // sprite1
rotate
Float
public
表示 LDisplayObject 实例距其原始方向的旋转程度,以度为单位。从 0 到 180 的值表示顺时针方向旋转;从 0 到 -180 的值表示逆时针方向旋转。对于此范围之外的值,可以通过加上或减去 360 获得该范围内的值。例如,my_video.rotate = 450语句与 my_video.rotate = 90 是相同的。
Default: 0
scaleX
Float
public
表示从注册点开始应用的对象的水平缩放比例(百分比)。默认注册点为 (0,0)。1.0 等于 100% 缩放。
Default: 1
scaleY
Float
public
表示从对象注册点开始应用的对象的垂直缩放比例(百分比)。默认注册点为 (0,0)。1.0 是 100% 缩放。
Default: 1
size
Int
public
使用此文本格式的文本的大小(以像素为单位)。
Default: 11
Example:
var theTextField = new LTextField();
theTextField.text = "size test";
theTextField.x = 10;
theTextField.y = 10;
theTextField.size = 20;
addChild(theTextField);
speed
Int
public
文本逐字显示的速度
Default: 0
Example:
LInit(50, "legend", 800, 480, main);
function main () {
var theTextField = new LTextField();
theTextField.text = "wait click";
theTextField.x = 10;
theTextField.y = 10;
theTextField.size = 20;
addChild(theTextField);
var button = new LButtonSample1("wind test start");
button.textField = theTextField;
button.x = 10;
button.y = 100;
addChild(button);
button.addEventListener(LMouseEvent.MOUSE_DOWN, onclick);
}
function windOver(event){
var theTextField = event.target;
theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
theTextField.text = "wind over";
}
function onclick(event){
var theTextField = event.currentTarget.textField;
if (theTextField.hasEventListener(LTextEvent.WIND_COMPLETE)) {
theTextField.removeEventListener(LTextEvent.WIND_COMPLETE, windOver);
}
theTextField.text = "TEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXTTEXT";
theTextField.speed = 3;
theTextField.wind();
theTextField.addEventListener(LTextEvent.WIND_COMPLETE, windOver);
}
stroke
String
public
文字描边效果。
Default: false
Example:
var theTextField = new LTextField();
theTextField.text = "stroke test";
theTextField.size = 50;
theTextField.stroke = true;
theTextField.lineWidth = 2;
theTextField.lineColor = "#FF0000";
addChild(theTextField);
styleSheet
LStyleSheet
public
将样式表附加到文本字段。有关创建样式表的信息,请参阅 LStyleSheet 类
Example:
var styleSheet = new LStyleSheet();
styleSheet.setStyle(".test","{color:#FF0000;font-size:40}");
styleSheet.setStyle("myText","{color:#008800;font-size:30}");
var theTextField = new LTextField();
theTextField.htmlText = "ABC<span class='test'>ABC<myText><i>ABC</i>ABC</myText>ABC</span>ABC<b>ABC</b><u>ABC</u>";
theTextField.x = 10;
theTextField.y = 100;
theTextField.styleSheet = styleSheet;
addChild(theTextField);
text
String
public
作为文本字段中当前文本的字符串。各行之间用回车符('\n')分隔。
textAlign
String
public
表示段落的对齐方式(水平)。
Default: left
textBaseline
String
public
表示段落的对齐方式(竖直)。
Default: top
transform
LTransform
public
一个对象,具有与显示对象的矩阵有关的属性。在 LTransform 类的条目中对特定属性 matrix 进行了说明。
transform 对象的每个属性本身都是一个对象。此概念很重要,因为设置 matrix 对象的新值的唯一方法是,创建新对象并将该对象复制到 transform.matrix 属性。
Example:
function main () {
var square = new LSprite();
square.graphics.drawRect(1, "#ff0000", [0, 0, 150, 100],true);
addChild(square);
square.addEventListener(LMouseEvent.MOUSE_UP, transformer);
}
function transformer(event) {
var square = event.currentTarget;
var tempMatrix = new LMatrix();
tempMatrix.skew(0.3, 0).translate(30,50);
square.transform.matrix = tempMatrix;
}
type
String
public
对象的类型
Default: LTextField
visible
Boolean
public
显示对象是否可见。不可见的显示对象已被禁用。例如,如果 LInteractiveObject 实例的 visible=false,则无法单击该对象。
Default: true
weight
String
public
规定字体的粗细。
Default: normal
Example:
var theTextField = new LTextField();
theTextField.text = "weight test";
theTextField.x = 10;
theTextField.y = 10;
theTextField.weight = "bolder";
addChild(theTextField);
width
Int
public
当设置换行有效(setWordWrap(true))的时候,可以通过它来设置文字宽度。
Default: 150
x
Float
public
表示 LDisplayObject 实例相对于父级 LDisplayObjectContainer 本地坐标的 x 坐标。如果该对象位于具有变形的 LDisplayObjectContainer 内,则它也位于包含 LDisplayObjectContainer 的本地坐标系中。因此,对于逆时针旋转 90 度的 LDisplayObjectContainer,该 LDisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。对象的坐标指的是注册点的位置。
Default: 0
y
Float
public
表示 LDisplayObject 实例相对于父级 LDisplayObjectContainer 本地坐标的 y 坐标。如果该对象位于具有变形的 LDisplayObjectContainer 内,则它也位于包含 LDisplayObjectContainer 的本地坐标系中。因此,对于逆时针旋转 90 度的 LDisplayObjectContainer,该 LDisplayObjectContainer 的子级将继承逆时针旋转 90 度的坐标系。对象的坐标指的是注册点的位置。
Default: 0
Events
LEvent.ENTER_FRAME
[播放事件] 播放头进入新帧时调度。
LFocusEvent.FOCUS_IN
LTextField对象获得焦点后调度。
LFocusEvent.FOCUS_OUT
LTextField对象失去焦点后调度。
LMouseEvent.DOUBLE_CLICK
不可用。
LMouseEvent.MOUSE_DOWN
不可用。
LMouseEvent.MOUSE_MOVE
不可用。
LMouseEvent.MOUSE_OUT
不可用。
LMouseEvent.MOUSE_OVER
不可用。
LMouseEvent.MOUSE_UP
不可用。