我正在为TileList实现我自己的CustomCellRenderer。它有我自己添加的按钮,但按钮除标签文本外不会显示任何内容。这是一段代码:
public class CustomCellRenderer extends ImageCell implements ICellRenderer
{
private var m_listData:ListData;
private var m_data:Object;
private var m_buyButton:Button;
public function CustomCellRenderer ()
{
m_buyButton = new Button();
m_buyButton.width = 25;
m_buyButton.height = 50;
m_buyButton.x = 40;
m_buyButton.y = 50;
m_buyButton.textField.text = "BUY";
m_buyButton.addEventListener(MouseEvent.CLICK, OnPurchaseClick);
addChild(m_buyButton);
}
private function OnPurchaseClick(e:Event):void
{
trace("PurchaseClick");
}
public override function set data(a_data:Object):void
{
label = "";
m_data = a_data;
}
public override function get data():Object
{
return m_data;
}
public override function set listData(a_listdata:ListData):void
{
m_listData = a_listdata;
}
public override function get listData():ListData
{
return m_listData;
}
}
“BUY”标签显示,因此按钮不在屏幕外,实际上是单元格的子节点,但由于某种原因,按钮外观没有显示,也不会点击任何鼠标。我尝试为按钮设置不同的皮肤,没有任何变化。我在这里不知所措,任何人都知道可能会发生什么?