2 Replies Latest reply on Jun 23, 2010 8:56 AM by Flex harUI

    Reference method within hierarchy

    Francisc Level 3

      Hello!

       

      Give this hierarchy:

       

      Application - Custom Component (with List component) - custom ItemRenderer

       

      I want to access a public method "hosted" in the Custom Component from inside the ItemRenderer.

       

      Is there a better way then Application.componentID.method() ?

       

      Thank you!

        • 1. Re: Reference method within hierarchy
          msakrejda Level 4

          I want to access a public method "hosted" in the Custom Component from inside the ItemRenderer.

          No you don't . "Reaching up" into a component's (or renderer's) environment like that is almost always a bad idea. The renderer should not care about where it's being used. If it needs a specific method from the hosting component, you could try passing it down through a ClassFactory property: e.g.,

           

          var rendererFactory:ClassFactory = new ClassFactory(CustomItemRenderer);

          rendererFactory.properties = { someFunction: this.doSomething };

          • 2. Re: Reference method within hierarchy
            Flex harUI Adobe Employee

            It depends on what assumptions you want to make, but owner.document should

            also work.