Home Flex Flex Custom mxml tags example
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Flex Custom mxml tags example

Advertisement
MXML files which functionalities are extended in to other mxml files are called Custom MXML components.

Flex custom mxml tags example

     

Flex .mxml files, whose functionalities are extended in to other Flex .mxml files are called custom mxml components. Custom mxml components are also referred to as custom mxml tags in the flex .mxml files in which their functionality is imported. Here, power.mxml is the custom mxml component whose functionality is been imported and used in the project.mxml file. Now in the base directory of  project.mxmli.e., C:\My Flex Folder, a folder solar is created and inside it the power.mxml file is placed. Now the complete folder path of power.mxml, i.e., solar.*  is put in to the MyComps names space. This MyComps  names space is used inside the project.mxml file to utilize the functionality of power.mxml file.

Now inside the <mx:Script > tags of power.mxml file, an include statement calls an action script file event.as. This action script file contains two functions with names Trinity and Neo respectively. Here, Neo is the event handler function. These functions are invoked  through the open and change attributes of flex combo box control. 

project.mxml

<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
  xmlns:MyComps = 
'solar.*' backgroundColor = '#CCFFFC'>

<MyComps:power/>

</mx:Application>

basedirectory

 

 

 

 

  

 

power.mxml

<?xml version = '1.0' encoding = 'utf-8'?>
<mx:Box xmlns:mx = 'http://www.adobe.com/2006/mxml'>

  <mx:Script>
  include 'includes/event.as';
  </mx:Script>

  <mx:HBox>
  <mx:ComboBox open = 'Trinity()' change = 'Neo(event)'>
  <mx:String> Morpheus</mx:String>
  <mx:String> Jonathan</mx:String>
  <mx:String> Nancy</mx:String>
  </mx:ComboBox>
  <mx:TextArea id = 'crown' color = 'green'/>
  </mx:HBox>

</mx:Box>

 

 

event.as

public function Trinity():void{
crown.text = '';
}

public function Neo(eve:Event):void{
crown.text = 'Value : ' + eve.currentTarget.value + '\n' +
'Index : ' + eve.currentTarget.selectedIndex;
}

project.swf

 

 

Download the code

Advertisements

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: September 9, 2008

Ask Questions?    Discuss: Flex Custom mxml tags example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Jonhy
March 8, 2012
project.swf

But, where is the project.swf file? Please, I need for understand it.
DMCA.com