Action Script custom components

You can create custom components by define Action Script class.

Action Script custom components

Flex Custom Components using Action Script:-

You can create custom components by define Action Script class. User can create two type of custom components. First is visual custom components like Button, LinkButton, CheckBox, ComboBox etc. components  and second is nonvisual components like formatter, validators subclasses. In this tutorial we have create a custom ButtonBar component. The process is that you will create a subclass of the Action Script component class and methods for the these custom components. If user want to used properties for that components then declear variable name and create setter and getter method for that custom components.

Example:-

buttonbar.as class code

package custocumponent

{

import flash.events.MouseEvent;

import mx.controls.Alert;

import mx.controls.Button;

import mx.controls.ButtonBar;

public class buttonBar extends ButtonBar {

public function buttonBar() {

super();

var mybutton1:Button = new Button();

mybutton1.label = "Submit";

this.addChild(mybutton1);

var mybutton2:Button = new Button();

mybutton2.label = "Login";

this.addChild(mybutton2);

var mybutton3:Button = new Button();

mybutton3.label = "Register";

this.addChild(mybutton3);

}

}

}

mainapplication.mxml code:

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

xmlns:MyComp="custocumponent.*"> 0

<MyComp:buttonBar/>

</mx:Application>

User download this code and run the output is: 1

Download this code