5 Replies Latest reply on Apr 21, 2009 9:43 AM by released87

    Custom Item Renderer Questions

    released87 Level 1

      Hi,

      I am using a Custom Item Renderer with a TileList Component. I have two buttons in the Custom ItemRenderer, but cannot call methods from the button, I will get the following error:


      1180: Call to a possibly undefined method accept.

       

      <mx:TileList x="75" id="tile_list" dataProvider="{outputData}" columnCount="1" width="200" height="1200" backgroundAlpha="0.1" >

       

       

       

           <mx:itemRenderer>

       

       

       

       

                <mx:Component>

       

       

       

       

                     <mx:Box width="100" height="150" horizontalAlign="center" rollOverEffect="Glow">

       

       

                          <mx:Button label="Accept Request" click="accept()" />

       

       

                          <mx:Label text="{data.username}" />

       

       

       

       

                          <mx:Button label="Deny Request" click="deny()" />

       

       

                     </mx:Box>

       

       

       

       

                </mx:Component>

       

       

       

       

           </mx:itemRenderer>

       

       

       

       

      </mx:TileList>

       

       

      However, I will not get the error if I paste the button outside that block of code. It seems the Component cannot access the parent methods, which makes sense because it is treated as an inline sub-component. How can I work around this?

        • 1. Re: Custom Item Renderer Questions
          Gregory Lafrance Level 6

          1) The method must be public, not private.

          2) You might need to call method this way:    outerDocument.accept()

          • 2. Re: Custom Item Renderer Questions
            Michael Borbor Level 4

            Yes you're right the renderer is given its own scope you could use 

            Application.application

             

            Sincerely,

             

            Michael

             

            El 21/04/2009, a las 10:41, released87 <forums@adobe.com> escribió:

             

            >

            Hi,

            I am using a Custom Item Renderer with a TileList Component. I have 

            two buttons in the Custom ItemRenderer, but cannot call methods from 

            the button, I will get the following error:

            >

            1180: Call to a possibly undefined method accept.

            >

            <mx:TileList x="75" id="tile_list" dataProvider="

            columnCount="1" width="200" height="1200" backgroundAlpha="0.1" >

            >

            >

            >

                 <mx:itemRenderer>

            >

            >

            >

            >

                      <mx:Component>

            >

            >

            >

            >

                           <mx:Box width="100" height="150" 

            horizontalAlign="center" rollOverEffect="Glow">

            >

                                <mx:Button label="Accept Request" 

            click="accept()" />

            >

                                <mx:Label text="{data.username}" />

            >

            >

            >

            >

                                <mx:Button label="Deny Request" click="deny()" />

            >

                           </mx:Box>

            >

            >

            >

            >

                      </mx:Component>

            >

            >

            >

            >

                 </mx:itemRenderer>

            >

            >

            >

            >

            </mx:TileList>

            >

            >

            However, I will not get the error if I paste the button outside that 

            block of code. It seems the Component cannot access the parent 

            methods, which makes sense because it is treated as an inline sub-

            component. How can I work around this?

            >

            • 3. Re: Custom Item Renderer Questions
              released87 Level 1

              I tried setting the method to public and it did not work. I will try targeting the parent component. How do you suggest? Should I use a parent method or target the component by name?

              • 4. Re: Custom Item Renderer Questions
                Gregory Lafrance Level 6

                outerDocument.accept();

                outerDocument.deny();

                • 5. Re: Custom Item Renderer Questions
                  released87 Level 1

                  thank you very much