意思是,如果我有:
<mx:Tree>
<!-- ... -->
</mx:Tree>
我希望通过执行(在AS中)来更改某些控件的行为或添加功能:
class ChristmasTree extends mx.controls.Tree {
// ...
}
如何更改MXML以便使用我的课程?
在the manual it says how to extend components via MXML中,但我该如何使用AS?
答案 0 :(得分:7)
好的,这是最好的懒人网。当然它也在TFM,实际上非常整洁。在AS中,您可以:
package myComponents
{
// as/myComponents/TextAreaFontControl.as
import mx.controls.TextArea;
public class TextAreaFontControl extends TextArea
{
// add / change behaviour, properties etc. ...
}
}
然后在MXML中执行:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:MyComp="myComponents.*">
<!-- ... -->
<MyComp:TextAreaFontControl />
冷却。
答案 1 :(得分:1)
我认为不是一回事......
你的第二个例子你只在主应用程序中导入一个自定义TextArea组件,你已经在TextAreaFontControl mxml文件中扩展了。 TextAreaFontControl是一个Component,你的情况是这样的:
<?xml version="1.0" encoding="utf-8"?>
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml">
<!-- her comes the Script block and other suff -->
</mx:TextArea>
通过从现有Component创建组件来扩展Component 什么垃圾邮件:-P