tags:

views:

703

answers:

2

Meaning, if I have:

<mx:Tree>
    <!-- ... -->
</mx:Tree>

and I want to change some of the control's behaviour or add functionality, by doing (in AS):

class ChristmasTree extends mx.controls.Tree {
    // ...
}

how do I change the MXML so that my class is used?

In the manual it says how to extend components via MXML, but how do I do it with AS?

+6  A: 

OK, that was lazyweb at its best. Of course it's also in TFM, and actually quite neat. In AS, you do:

package myComponents
{
    // as/myComponents/TextAreaFontControl.as    
    import mx.controls.TextArea;

    public class TextAreaFontControl extends TextArea 
    {

        // add / change behaviour, properties etc. ...

    }

}

and then in MXML, you do:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
   xmlns:MyComp="myComponents.*">

<!-- ... -->

<MyComp:TextAreaFontControl />

Cool.

Hanno Fietz
A: 

i think not really the same thing...

your second example u only a import of a custom TextArea component in the main application, that u have already extended in the TextAreaFontControl mxml File. The TextAreaFontControl is a Component, your case something like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:TextArea xmlns:mx="http://www.adobe.com/2006/mxml"&gt;
    <!-- her comes the Script block and other suff -->
</mx:TextArea>

U extend a Component, by creating a component from an existing Component What a crap sentance :-P

Grauzone