1 Reply Latest reply on Dec 18, 2007 6:43 AM by Gregory Lafrance

    Share code between modules

    Zolotoj Level 3
      I have a main application that a user can fire other modules from. I would want to have common code being loaded in main application and shared my modules to use. What is a way of doing this?
        • 1. Re: Share code between modules
          Gregory Lafrance Level 6
          This FB help topic might be of use:
          Accessing Document and Application object scopes

          In your application's main MXML file, the file that contains the <mx:Application> tag, you can access the methods and properties of the Application object using the this keyword. However, in custom ActionScript and MXML components, event listeners, or external ActionScript class files, Flex executes in the context of those components and classes, and the this keyword refers to the current Document object and not the Application object. You cannot refer to a control or method in the application from one of these child documents without specifying the location of the parent document.

          Flex provides the following properties that you can use to access parent documents:

          mx.core.Application.application The top-level Application object, regardless of where in the document tree your object executes.

          mx.core.UIComponent.parentDocument The parent document of the current document. You can use parentDocument.parentDocument to walk up the tree of multiple documents.

          mx.core.UIComponent.parentApplication The Application object in which the current object exists. Flex applications can load applications into applications, therefore, you can access the immediate parent application by using this property. You can use parentApplication.parentApplication to walk up the tree of multiple applications.