views:

369

answers:

2

Hi, this is a pretty basic question but I can't seem to get it right.

If I want to extend an existing component, what is the right way to do it? For example, this thread talks about it, but doesn't give an example: http://stackoverflow.com/questions/710646/flex-datechooser-events-for-individual-days

A simple example of just adding a trace("this is my function") to an existing function of a component would be helpful.

Thanks.

A: 

Use Proxy. Example in the link.

dirkgently
Thanks, but the reason I posted the question here is because I find the adobe docs to be unhelpful.
Martholomew
@Martholomew: Have you tried the examples?
dirkgently
+1  A: 

A simple example to make a component that extends the Button component in ActionScript:

package custom
{
   import mx.controls.Button;
   import flash.events.MouseEvent;

   public class CustomButton extends Button {

      public function CustomButton() {
         super();
      }

   override protected function clickHandler(event:MouseEvent):void {
      trace('clickHandler is overwritten!');
   }
}

You can enter the component in your MXML like this:

<custom:CustomButton id=”customBtn” label=”Custom Button” />

Hope it helps some!

Daisy
thanks so much for the help!
Martholomew