Share on Google+Share on Google+

Flex current target property example

Example below describes the working of currentTarget property in flex. Code below shows a method .setSelection which is used to highlight the text letters as defined closed indexes.

Flex current target property example


The example below describes the working flex currentTarget property. Code below shows a method .setSelection which is used to highlight the text letters as per defined closed indexes. Here, use of <![CDATA --- ]]>  is optional. In the code, two functions are defined, viz.,  protocol and virus; both are event handler functions. First method defines the Label control id and  puts data in to core.text, where text is the attribute defined in TextInput control and the second function highlights the text characters from index 5 to 20 in TextInput. Both are click based event functions, however the protocol function gets initialized first because it is passed in the initialize attribute of the root tag. Root tag is coded as <Application/>, and is called as the root tag of the application inside which other flex control and container tags are coded. 






<?xml version = '1.0'?>
<mx:Application xmlns:mx = ''>

  public function protocol(event:Event):void{
master.text = 'Label' + + 'is clicked';
core.text = 'Weaving = Agent Smith said that in an 
interview about Matrix Reloaded

  public function virus(event:Event):void{

<mx:TextInput id = 'core' text = 'click on me
lick = 'virus(event);' />
  <mx:Label id = 'master' click = 'protocol(event);'/>



In the code below event.current.Target feature is used in the function constructor. Function is called through the click attribute of Button control.


<?xml version = '1.0' encoding = 'ISO-8859-1'?>
<mx:Application xmlns:mx = ''>
  import mx.controls.Alert;

  public function nick(s:String):void{'Button control id is : ' + s);


  <mx:Button label = 'Click me' id = 'Cathastorus
  click = 'nick('/>




Download the source code



Posted on: September 9, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: Flex current target property example  

Post your Comment

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