6 Replies Latest reply on May 6, 2009 6:16 PM by Gregory Lafrance

    Problem with the click property in an embeded component

    Jim Daniel Level 1

      The following code snipit causes the -- 1180: Call to a possibly undefined method myLink. -- compile time error.  I've tried making the method public and that doesn't help, so can anyone tell me what's going wrong?

       

       

       

       

       

      <mx:TileList x="148" y="10" width="411" height="302" rowHeight="140" columnWidth="190"

           dataProvider="{clientsList}" backgroundColor="#E9EEF0" rollOverColor="#b1b5b6" click="myLink('{data.link}')">

            <mx:itemRenderer>

                <mx:Component>
                     <mx:VBox horizontalAlign="center" verticalAlign="middle" height="140" width="200" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                          <mx:Image source = "{data.image}" width="120" height="100" toolTip="{data.text}" click="myLink('{data.link}')"/>
                          <mx:Text width="100%" text="{data.name}" textAlign="center" height="18" fontSize="12" fontFamily="Myriad Pro"/>
                     </mx:VBox>
                </mx:Component>

           </mx:itemRenderer>
      </mx:TileList>

        • 1. Re: Problem with the click property in an embeded component
          Michael Borbor Level 4

          Where do you place your function? I don't think square brackets are necessary in the function call.

          • 2. Re: Problem with the click property in an embeded component
            Jim Daniel Level 1

            Small error in the code previously shown.  Here is the corected code

             

             

             

             

             

            <mx:TileList x="148" y="10" width="411" height="302" rowHeight="140" columnWidth="190"

                 dataProvider="{clientsList}" backgroundColor="#E9EEF0" rollOverColor="#b1b5b6">

                  <mx:itemRenderer>

                      <mx:Component>
                           <mx:VBox horizontalAlign="center" verticalAlign="middle" height="140" width="200" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                                <mx:Image source = "{data.image}" width="120" height="100" toolTip="{data.text}" click="myLink('{data.link}')"/>
                                <mx:Text width="100%" text="{data.name}" textAlign="center" height="18" fontSize="12" fontFamily="Myriad Pro"/>
                           </mx:VBox>
                      </mx:Component>

                 </mx:itemRenderer>
            </mx:TileList>

            • 3. Re: Problem with the click property in an embeded component
              Jim Daniel Level 1

              If by square brackets you mean the {} brakets, then they are of no significance to this problem.  I've tried using just a function call with no variable passing i.e. click="myLink()"

              • 4. Re: Problem with the click property in an embeded component
                Michael Borbor Level 4

                First make sure myLink is public and second call myLink like this outerDocument.myLink

                • 5. Re: Problem with the click property in an embeded component
                  Michael Borbor Level 4

                  Yes sorry, I meant brackets I must remember to never look at code without my glasses.

                  • 6. Re: Problem with the click property in an embeded component
                    Gregory Lafrance Level 6

                    Here tis:

                     

                    <?xml version="1.0"?>
                    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
                      <mx:Script>
                        <![CDATA[
                          public function myLink(url:String):void{
                            navigateToURL(new URLRequest('http://www.' + url), '_blank');
                          }
                        ]]>
                      </mx:Script>
                      <mx:XML xmlns="" id="clientsList">
                        <items>
                          <item>
                            <name>Google's Headquarters</name>
                            <image>google.png</image>
                            <link>google.com</link>
                            <text>A picture of Google's headquarters.</text>
                          </item>   
                          <item>
                            <name>Yahoo's Headquarters</name>
                            <image>yahoo.png</image>
                            <link>yahoo.com</link>
                            <text>A picture of Yahoo's headquarters.</text>
                          </item>
                        </items>   
                      </mx:XML>
                      <mx:TileList x="148" y="10" width="411" height="302"
                        rowHeight="140" columnWidth="190" dataProvider="{clientsList..item}"
                        backgroundColor="#E9EEF0" rollOverColor="#b1b5b6">
                        <mx:itemRenderer>
                          <mx:Component>
                            <mx:VBox horizontalAlign="center" verticalAlign="middle"
                              height="140" width="200" horizontalScrollPolicy="off"
                              verticalScrollPolicy="off">
                              <mx:Image source = "{data.image}" width="120" height="100"
                                toolTip="{data.text}" click="outerDocument.myLink(String(data.link));"/>
                              <mx:Text width="100%" text="{data.name}" textAlign="center"
                                height="18" fontSize="12" fontFamily="Myriad Pro"/>
                            </mx:VBox>
                          </mx:Component>
                        </mx:itemRenderer>
                      </mx:TileList>
                    </mx:Application>