2 Replies Latest reply on May 9, 2008 11:15 PM by Gregory Lafrance

    Calling custom mxml components

      How to I call an mxml component from an mxml application where the first called mxml component calls another mxml component.
        • 1. Re: Calling custom mxml components
          EvolvedDSM Level 2
          Far as I know, your main mxml application needs to call the component that contains your other component.

          In the <application> tag of your main mxml, setup up a reference point to correspond to the location of your components (we'll call the reference 'comp1' and assume it points to a project folder named 'components' which contains both of your components).

          <application ... xmlns:comp1="components.*" ...>

          Any time you need to include your first component in your main application mxml, you can reference it as <comp1:component_name .../> where component_name is the name of your first component.

          Now, within your first component (we'll assume it's base is canvas, though it could be a number of containers such as HBox, etc), you'll need to declare a reference point again in the same fashion, except within your container's tag since it won't have an application tag.

          <canvas ... xmlns:comp2="components.*" ... >

          Now that we've declared this, you can place your 2nd component into your 1st component the same way you placed your 1st component into your main application. This time specify the 2nd component name
          <comp2:component_name2 ... />

          Hope this is what you are looking for
          • 2. Re: Calling custom mxml components
            Gregory Lafrance Level 6
            Please state specifically who owns what. Is it this:

            Main app
            - comp1
            - comp2

            In that case you can access comp2 from comp1 by application.comp2.propertyOrFunction