Actionscript 3 按钮皮肤未显示为addElement();
我在ActionScriptt中创建了一个类,它扩展了spark.components.Button,因为我将在运行时加载一组按钮。我有一个SkinnableContainer.mxml文件,spark按钮将加载到该文件中。当我在mxml文件中使用addElement()方法时,我的按钮的自定义外观不会显示出来Actionscript 3 按钮皮肤未显示为addElement();,actionscript-3,flex4,flash-cs5,Actionscript 3,Flex4,Flash Cs5,我在ActionScriptt中创建了一个类,它扩展了spark.components.Button,因为我将在运行时加载一组按钮。我有一个SkinnableContainer.mxml文件,spark按钮将加载到该文件中。当我在mxml文件中使用addElement()方法时,我的按钮的自定义外观不会显示出来 //in the SkinnableContainer.mxml file public function displayButton(button:Button):void {
//in the SkinnableContainer.mxml file
public function displayButton(button:Button):void
{
addElement(button);
}
但是,如果在同一个SkinnableContainer.mxml文件中,我通过
<mybuttons:CustomButton x="73" y="4"/>
在我添加了按钮元素之后,按钮仍然没有蒙皮
有什么想法吗?正如shaunhusain所说,您的方法是寻找一个火花按钮,而不是我认为处理蒙皮的自定义按钮 不管怎样,在方法内部,您可以使用setStyle将皮肤应用于传递的按钮
public function displayButton(button:Button):void
{
button.setStyle("skinClass", your.button.SkinClass);
addElement(button);
}
在displayButton方法中,您将参数键入为Button而不是CustomButton,您确定要向其中传递CustomButton吗?在将元素添加到显示树后,您不需要重新加载样式声明,只要样式已注册且组件实现了样式的使用,就应该应用样式声明。谢谢,我将尝试一下
public function displayButton(button:Button):void
{
button.setStyle("skinClass", your.button.SkinClass);
addElement(button);
}