Action Script custom components

You can create custom components by define Action Script class.


 
Ads

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.*">

<MyComp:buttonBar/>

</mx:Application>

User download this code and run the output is:

Download this code

Advertisements

Share on Google+Share on Google+

Action Script custom components

Posted on: July 13, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: Action Script custom components  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads