Flex 启动基本流程

来源:互联网 发布:太平洋电脑网 软件 编辑:程序博客网 时间:2024/06/08 11:47
  1. First, enough bytes for frame 1 are streamed down to the Flash Player.
  2. The Flash Player executes those bytes by creating a SystemManager instance.
  3. SystemManager instruct the Flash Player to stop at the end of frame 1.
  4. SystemManager then goes on to create the Preloader which creates the DownloadProgressBar control and pops that up on the client screen.
    1. The Preloader then starts tracking the rest of the bytes streaming in from the Flex SWF (or from external SWFs).
      Once all the bytes for the Flex framework and application code are in, the System Manager goes on to frame 2 and instantiates the Application instance.
    2. All RSLs and their associated classes are now loaded [into the ApplicationDomain]; note that the load order is in the order defined during app compile time.[3]
    • All class definitions used by the application (views, logic, etc) must be loaded prior to Frame 2. It is here, in Frame1, that your preloader code can even install patches to the Flex framework BEFORE the framework classes themselves are loaded.
    • This technique is called "monkey-patching" and will be used later
      when we are discussing the decryption process.
    1. Once the Application instance has been created, the SystemManager sets Application.systemManager to itself. This is how you, the application developer, can access the SystemManager at a later time.
    2. The Application dispatches the preinitialize event at the beginning of the initialization process.
    3. Application goes on to create its children. The method createChildren() is called on the application. At this point each of the application’s components is being constructed, and each component’s createChildren() will be also called. For detail, look at component lifecycle section.
    4. The Application dispatches the initialize event, which indicates that all application’s components have been initialized. However, at this state, all the components are not yet laid out.
    5. Eventually, once all the Application child controls and containers have been created, sized and positioned, the Application dispatches the creationComplete event.
    6. Once the creationComplete event has been dispatched, the Preloader removes the DownloadProgressBar control and the SystemManager adds the Application instance to the Flash Player display list. (The Flash Player display list is basically the tree of visible or potentially visible objects that make up your application. When you add and remove child components to your application, your basically just adding and removing them from the display list).
    7. Once the Application is added to the Flash Player display list, the Application dispatches its applicationComplete event
    8. The Application has been created and is up on the screen ready to be interacted with.