Apache flex 在Flex中扩展MX类时,如何在MXML中引用它?

Apache flex 在Flex中扩展MX类时,如何在MXML中引用它?,apache-flex,oop,Apache Flex,Oop,意思是,如果我有: <mx:Tree> <!-- ... --> </mx:Tree> 如何更改MXML以便使用我的类 在中,但我如何使用AS?好的,这是lazyweb的最佳状态。当然,它也在里面,实际上相当整洁。在AS中,您需要: package myComponents { // as/myComponents/TextAreaFontControl.as import mx.controls.TextArea;

意思是,如果我有:

<mx:Tree>
    <!-- ... -->
</mx:Tree>
如何更改MXML以便使用我的类


在中,但我如何使用AS?好的,这是lazyweb的最佳状态。当然,它也在里面,实际上相当整洁。在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 />


很酷。

我觉得不太一样

第二个示例是在主应用程序中仅导入自定义TextArea组件,该组件已在TextAreaFontControl mxml文件中扩展。TextAreaFontControl是一个组件,您的案例如下:

<?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>

U通过从现有组件创建组件来扩展组件 多么糟糕的一句话:-P

<?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>