[an error occurred while processing this directive]

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

                         

[an error occurred while processing this directive]