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



Home Flex Flex target property example

Related Tutorials


 
 

Share on Google+Share on Google+

Flex target property example

Advertisement
In coding the below flex application we have use an event object property target .

Flex target property example

     

In coding the below flex application we have use an event object property  target . We also have another event object property currentTarget. 
These properties enables the programmer to  track the event of which the object is made, during the event's propagating process. Properties target and currentTarget differ in their targeting jobs.  target property may dispatch the event to a component or component's sub component, whereas currentTarget will target the event to a particular node in which the event listener (function in which the event object is made) is called or tested.

Syntax for using these object properties
 
event.target.label
 
event.currentTarget.label

Target.mxml

<?xml version = '1.0' encoding = 'utf-8'?>
<mx:Application xmlns:mx = 'http://www.adobe.com/2006/mxml'
 initialize = 'clickListener()'>
  <mx:Script>
  <![CDATA[
  
  public function roseindia(event:Event):void{
  var url:URLRequest;
  url = new URLRequest('http://www.roseindia.net/'
 + event.target.label);
  
  navigateToURL(url);
  }

  public function google(event:Event):void{
  var url:URLRequest = new URLRequest(
  'http://www.google.com/search?hl=en&q='
 + event.target.label);
  
  navigateToURL(url);
  }
  public function googleImage(event:Event):void{
  var url:URLRequest = new URLRequest(
  'http://images.google.com/images?hl=en&q=' 
  + event.target.label);
  
  navigateToURL(url);
  }
  
  public function clickListener():void{
  Panel_0.addEventListener(MouseEvent.CLICK, 
  roseindia);  
  Panel_1.addEventListener(MouseEvent.CLICK, 
  google);  
  Panel_2.addEventListener(MouseEvent.CLICK, 
  googleImage);  
  }  

  ]]>
  </mx:Script>
  
  
  
  <mx:VBox width = '100%' height = '100%'>
  
  <mx:Panel id = 'Panel_0' title = 'Roseindia techno
  logies'  width = '30%' height = '40%
  color = 'green' backgroundColor = '#660033'>
  
  <mx:HBox>
  <mx:VBox>
  <mx:LinkButton label = 'java'/>
  <mx:LinkButton label = 'flex'/>
  <mx:LinkButton label = 'ant'/>
  <mx:LinkButton label = 'ajax'/>
  </mx:VBox>
  
  <mx:VBox>
  <mx:LinkButton label = 'jsp'/>
  <mx:LinkButton label = 'hibernate'/>
  <mx:LinkButton label = 'spring'/>
  </mx:VBox>
  </mx:HBox>
  

  
  </mx:Panel>

  <mx:Panel id = 'Panel_1' title = 'Google web
  backgroundColor = '#CCFF66' width = '30%'
  height = '40%' color = 'red'>
  

  <mx:VBox>
  <mx:LinkButton label = 'newstrackindia.com'/>
  <mx:LinkButton label = 'livetechtalk.com'/>
  <mx:LinkButton label = 'allcooljobs.com'/>
  <mx:LinkButton label = 'javajazzup.com'/>
  </mx:VBox>

  </mx:Panel>  
  
  <mx:Panel id = 'Panel_2' title = 'Google images
  width = '30%' height = '40%' backgroundColor
 '#6633CC' color = 'blue'>  
  <mx:VBox>
  
  <mx:LinkButton label = 'Rachel weisz'/>
  <mx:LinkButton label = 'Trinity'/>
  <mx:LinkButton label = 'neo'/>
  <mx:LinkButton label = 'vampire'/>
  
  </mx:VBox>
  
  </mx:Panel>
  
  </mx:VBox>
</mx:Application>

Target.swf

 

Download the 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: June 11, 2009

Related Tutorials

Discuss: Flex target property example  

Post your Comment


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