2

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: 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.

Community
  • 1
  • 1
Martholomew
  • 89
  • 1
  • 8

2 Answers2

2

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!

Marjolein
  • 116
  • 5
0

Use Proxy. Example in the link.

dirkgently
  • 108,024
  • 16
  • 131
  • 187