ActionScript can be used to create custom components. In the example below, a custom button component is created by extending Button class.
|
package
mycomp
{
import
mx.controls.Button;
public
class
MyCustomButton
extends
Button {
public
function
MyCustomButton() {
super();
label="My
Button";
height=30;
width=100;
}
}
} |
To use this component in mxml file (CustomButtonExample.mxml), set xmlns property to the custom component like xmlns:CompRI="mycomp.*". This indicates that the prefix CompRI will be used to refer any component in mycomp package.
|
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
xmlns:CompRI="mycomp.*">
<CompRI:MyCustomButton/>
</mx:Application> |
Running the example renders output as below:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.