[]自己写了个label继承官方的label,出现了问题,求指导~

问题是,用官方label是没有问题的,用自己写的label就无法显示了,但是无报错,求解决~~DemoLabel类:
package
{
// import laya.ui.Label;
import laya.webgl.WebGL;

public class DemoLabel
{
public function DemoLabel()
{
Laya.init(800, 600, WebGL);
Laya.stage.bgColor = "#232628";


//---------------------------------这是用我自己写的label继承了官方的label,问题是label显示不出来,但是也无报错--------------------------------------------
var label:Label = new Label();
var textFormat:TextFormat = new TextFormat("Microsoft YaHei", 50, "#FF00FF", true, true, true);
label.textFormat = textFormat;
label.wordWrap = true;
label.lWidth = 100;
label.lHeight = 100;
label.txt = "Hello";
label.lx = 100;
label.ly = 100;
Laya.stage.addChild(label);


//---------------------------------这是用官方的api,无问题--------------------------------------------
// var label:laya.ui.Label = new laya.ui.Label();
// label.text = "Hello";
// label.fontSize = 50;
// label.color = "#FF00FF";
// label.wordWrap = true;
// label.width = 100;
// label.height = 100;
// label.x = 100;
// label.y = 100;
// Laya.stage.addChild(label);
}
}
}
自己写的label类:
package
{
import laya.ui.Label;
/**
* 继承官方的label
* @author Administrator
*
*/
public class Label extends laya.ui.Label
{
private var _textFormat:TextFormat;
private var _txt:String;
private var _lWidth:int;
private var _lHeight:int;
private var _lx:int;
private var _ly:int;

public function Label(text:String="")
{
super(text);

}

public function get textFormat():TextFormat
{
return _textFormat;
}
public function set textFormat(value:TextFormat):void
{
_textFormat = value;

font = _textFormat._font;
fontSize = _textFormat._fontSize;
color = _textFormat._color;
bold = _textFormat._bold;
italic = _textFormat._italic;
underline = _textFormat._underline;
padding = String(_textFormat._leftMargin);
// leftMargin = value.leftMargin;
// rightMargin = value.rightMargin;
// indent = value.indent;
// leading = value.leading;

}

public function get txt():String
{
return _txt;
}

public function set txt(value:String):void
{
_txt = value;
text = _txt;
}

public function get lWidth():int
{
return _lWidth;
}

public function set lWidth(value:int):void
{
_lWidth = value;
width = _lWidth;
}

public function get lHeight():int
{
return _lHeight;
}

public function set lHeight(value:int):void
{
_lHeight = value;
height = _lHeight;
}

public function get lx():int
{
return _lx;
}

public function set lx(value:int):void
{
_lx = value;
x = _lx;
}

public function get ly():int
{
return _ly;
}

public function set ly(value:int):void
{
_ly = value;
y = _ly;

}
}
}
TextFormat类:
package
{


public class TextFormat
{
public var _font:String;
public var _fontSize:int;
public var _color:String;
public var _bold:Boolean;
public var _italic:Boolean;
public var _underline:Boolean;
public var _leftMargin:Object;
public var _rightMargin:Object;
public var _indent:Object;
public var _leading:Object;

public function TextFormat(font:String = "方正粗圆_GBK", size:int = 20, color:String = "#FFFF00",
bold:Boolean = false, italic:Boolean = false, underline:Boolean = false,
url:String = null, target:String = null, align:String = null,
leftMargin:Object = null, rightMargin:Object = null,
indent:Object = null, leading:Object = null)
{
//Config.fontName, 18, LIST_LABEL_COLOR,
//false, false, false,
//null, null, TextFormatAlign.LEFT,
//0, 0, 0, 0
_font = font;
_fontSize = size;
_color = color;

_bold = bold;
_italic = italic;
_underline = underline;

// _url = url;//没用到
// _target = target;//没用到
// _align = align;

_leftMargin = String(leftMargin);
_rightMargin = String(rightMargin);
_indent = String(indent);
_leading = String(leading);
console.log("font==="+_font, "size==="+_fontSize, "color==="+_color, "bold==="+_bold, "italic==="+_italic,
"underline==="+_underline,"leftMargin==="+_leftMargin, "rightMargin==="+_rightMargin);

}

}
}
已邀请:

survivor - 翻身做咸鱼

赞同来自: ht657990995

Label.as lineno 38
padding = String(_textFormat._leftMargin);
padding的格式是'top,right,bottom,left'形式的字符串。不是接受单边边距。而且这里的_textFormat._leftMargin是undefined.

要回复问题请先

商务合作
商务合作