4 Replies Latest reply on May 30, 2006 9:06 AM by ntsiii

    using MXML in ActionScript

    bendev
      Hello,
      There are many chapters describing how to use 'ActionScript in MXML' but I have found none about the opposite : how to perform the installation of a component embedded in a .mxm file starting from an AS class, for example.
      Is that possible with FLEX2 ?

      Thank you for any help
      Ben
        • 1. Re: using MXML in ActionScript
          GordonSmith Level 4
          Yes. Regardless of whether you've written MyComponent.mxml or MyComponent.as, you can import MyComponent, use the 'new' operator to create an instance of it, and addChild() to add it to a parent component. Here's an example that assumes that the three files are in the same directory. It shows how to add an instance of the MXML component MyButton to the AS component MyBox. If you need your application to be AS instead of MXML, there are some additional complications.

          • 2. Re: using MXML in ActionScript
            poonamsheth Level 1
            wow its gr8 explained
            • 3. Re: using MXML in ActionScript
              ramasatoskar
              Hi ,
              Is it true that in a project we should have as many actionscript files as possible and only one mxml file. Is it a part of good practise of programming or some functionality enhancer.

              Also i would like to how to make great use of the examples available at the adobe site for fles. For eg: Flickr API .

              Kindly help
              • 4. Re: using MXML in ActionScript
                ntsiii Level 3
                "...as many actionscript files as possible and only one mxml file..." No, this generalization is not correct.

                The primary purpose of mxml is to increase productivity. Use whichever type of code works best for your particular task, component, etc.

                When the app is compiled, the mxml is converted to as, then to swf, so there is no performance difference to the end user.

                Tracy