【发布时间】:2012-03-26 15:17:03
【问题描述】:
我在 actionscritpt 中创建了一个扩展 spark.components.Button 的类,因为我将在运行时加载一堆按钮。我有一个 SkinnableContainer.mxml 文件,火花按钮将被加载到该文件中。当我在该 mxml 文件中使用 addElement() 方法时,我的按钮的自定义外观不会显示。
//in the SkinnableContainer.mxml file
public function displayButton(button:Button):void
{
addElement(button);
}
但是,如果在同一个 SkinnableContainer.mxml 文件中,我将其放入 via
<mybuttons:CustomButton x="73" y="4"/>
皮肤显示得很好。
我想可能是因为在调用 loadStyleDeclarations 后添加了按钮,这可能是问题所在,所以我调用了
styleManager.loadStyleDeclarations(skin, true, true, ApplicationDomain.currentDomain);
在我添加按钮元素后,按钮仍然没有皮肤。
有什么想法吗?
【问题讨论】:
-
在 displayButton 方法中,您将参数键入为 Button 而不是 CustomButton,您确定将 CustomButton 传递给它吗?将元素添加到显示树后不需要重新加载样式声明,只要注册了样式并且组件实现了样式的使用,就应该应用它们。
-
谢谢,我会试一试
标签: actionscript-3 flex4 flash-cs5