Select to view content in your preferred language

Function error 1120: Access of undefined property

1360
2
05-05-2011 11:08 AM
RobertMyers
Deactivated User
The below function works in a separete mxml file in my project. (It's a item renderer mxml file for a datagrid.) But when I bring the code into the main application mxml file it does not work. I get the error "1120: Access of undefined property data." Can anyone tell me why I am getting this error?

<fx:Script>
        <![CDATA[
                        protected function email_clickHandler(event:MouseEvent):void
            {
                var request:URLRequest = new URLRequest("mailto:" + data.Email_1_13 + "?subject=" + data.Full_Addre);
                navigateToURL(request,"_self");
            }
                    ]]>
    </fx:Script>
Tags (2)
0 Kudos
2 Replies
ReneRubalcava
Esri Frequent Contributor
It depends on what the event listener is acting upon.
ItemRenderers are built to work in Lists/DataGrids that will have a collection of objects.
The data object is a reference to that particular item that is selected in a List.

Now that you have moved it to your main index.mxml file, what is the function acting upon? I see you're using a MouseEvent, so I assume a Button click. Where the email source coming from when you click that button?
0 Kudos
RobertMyers
Deactivated User
Actually it's a click event on a Label component for each situation. But you did give me a clue.

I noticed that the Label being clicked was within infoWindowRenderer and within that was a place for fx:script. I move the function there and it worked. Thank you.


      <esri:infoWindowRenderer>
       <fx:Component>
       
        <mx:VBox  fontWeight="bold" label="{data.Full_Addre}">
        
         <fx:Script>
      
          <![CDATA[
           protected function email_clickHandler(event:MouseEvent):void
           {
            var request:URLRequest = new URLRequest("mailto:" + data.Email_1_13 + "?subject=" + data.Full_Addre);
            navigateToURL(request,"_self");
           }
          
          ]]>
         
         </fx:Script>
        
         <s:Label textDecoration="underline" color="blue" baselineShift="2" text="Email: { data.Email_1_13 }" click="email_clickHandler(event)"/>
        
        </mx:VBox>
       </fx:Component>
      </esri:infoWindowRenderer>
0 Kudos