Home Tutorial Flex Flex-components Creating Flex ActionScript Custom Component extending Button

 
 

Share on Google+Share on Google+
Creating Flex ActionScript Custom Component extending Button
Posted on: April 12, 2010 at 12:00 AM
Advertisement
ActionScript can be used to create custom components. In the example below, a custom button component is created by extending Button class.
Creating ActionScript components

Creating Flex ActionScript Custom Component extending Button

 

ActionScript can be used to create custom components. In the example below,  a custom button component is created by extending Button class.

 

For this, create a actionscript class ?MyCustomButton.as? in a package mycomp and extends from Button class. Here label, height and width are modified.

MyCustomButton.as

 

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.

 

CustomButtonExample.mxml

 

<?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:

 

Advertisement

Related Tags for Creating Flex ActionScript Custom Component extending Button:


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: April 12, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com