Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Flex Action Script custom components

Related Tutorials


 
 

Share on Google+Share on Google+

Action Script custom components

Advertisement
You can create custom components by define Action Script class.

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

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 13, 2010

Related Tutorials

Discuss: Action Script custom components  

Post your Comment


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