2 Replies Latest reply on Oct 8, 2010 5:20 AM by nextisme

    Dynamic Generation of MXML code


      I have a flex application which loads another sub-application.


      The parent application has tools which allows the user to add a component to the sub-application and modify some of the component's properties (for eg. when the user clicks on the text box tool in the parent application, a text area component gets added to the sub-application).


      Now how can I modify/create-new mxml code for the sub-application reflecting the additions made by the user at runtime?


      (This application somewhat immitates what a user gets to do in the design mode in flash builder where the mxml code gets generated behind the scenes. So can I make use of flash builder by implementing some of its methods or extending its classes etc to get the job done?)

        • 1. Re: Dynamic Generation of MXML code
          pauland Level 4

          You use actionscript. MXML is just a convenient notation. You can't (easily) create MXML on the fly and compile it.

          • 2. Re: Dynamic Generation of MXML code
            nextisme Level 1

            Its true that mxml is just a conveniant notation and that's why I feel it is suitable for what I intend to do. All what is really being done here is to save the state of the sub-application swf so that it can be edited again later. So a conveniant notation is exactly what it needed.


            For this I do have to create MXML on the fly. However there is no real need to compile it at the same time. This is because running the sub-application would already be a visual representation of the modified mxml, although I do realize that it is not the compiled version of the modified mxml. This would work assuming that the modifications made to the sub-application at runtime translate accurately into mxml to the extent that there would be no difference between the currenlty playing swf file and the compiled swf of the modified mxml. This process would also eliminate the need for repetitive compilation which can ultimately be done once the user chooses to save the changes.