extending an existing flex component
-
23-08-2019 - |
Question
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.
Solution
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!
OTHER TIPS
Use Proxy. Example in the link.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow