1. The life cycle of Flex application
Flex applications are fundamentally Flash applications, but they are developed based on Flex Framework (written by ActionScript). The root object of the Flex application is SystemManager (not the Application root element we see on the flex application), inherited from the -flash player display type. MovieClip is an object that supports the frame frame of the timeline basic element. In the Flex Framework, SystemManager is special, containing two frames (other components are one frame), namely preloader and the real Application. The preloader frame can be downloaded quickly and used to display the application download progress. Once the SystemManager instance of the Flex application enters the second frame, a Flex main application application instance will be created and the attribute application (null before entering the second frame). From then on, the internal life cycle and event of the application (flex main application) begins to operate:
preinitialize: The application has been instantiated but no child component has been created yet
initialize: child component has been created but layout it (lay out)
creationComplete: The application has been instantiated and the layout of all child components has been completed.
SystemManager has a topLevelSystemManager object that points to a SystemManager instance, which is the root of everything currently running in the flash player. If the flex is loaded into the flash player as the main application, the above attribute will point to itself (self-refrencing). However, when the flex application is loaded by another flex application, its own topLevelSystemManager's attribute is not self-referencing, but to its parent application's SystemManager instance. All subclasses of UIComponents have a systemManager attribute pointing to the application SystemManager instance. When the event of the component listened to by the SystemManager instance bubbles, it will have the last processing rights on the event processing chain.
2. The difference between Flash player and Framework
Flash player is the running environment of Flex applications and flash applications. The two applications have completely equal operating rights (through the API provided by Flash player). The .swf files formed by the two applications are the same in flash player. The difference is not the content of the application but their respective creation methods. Flex's Framework provides an abstraction for applications between development and operation. When compiling the Flex application, the necessary framwork library will be compiled into .swf files (also affecting the size of the application file, etc.). The main flash player class will of course not be compiled into .swf, because they already exist in the flash player, and eventually form the same flash player as the flash application can understand.
The difference between flash player class and flex framework is very convenient. The former class starts with flash, such as, while the latter starts with mx, such as
3. Dynamically load another flex application
<mx:SWFLoader source=”src/*.swf”/>
The content property of Swfloader points to the SystemManager instance of the loaded flex application (it application property points to the Application instance of the loaded felx application). When the swfloader loads and initializes the loaded flex application, it will dispatch the init event, which can be used to listen to the ApplicationComplete event of the SystemManager instance loaded flex application. When the event occurs, the Application object that loaded content can be referenced.
with inithandler (FlexEvent.APPLICATION_COMPLETE,func);
With applicationCompleteHandler...
4. Understand the application domain
An application domain (similar to the appdoamin of .net) contains class definitions, resources, etc. of flex applications. The loaded new flex application can exist in a brand new, isolated domain (occupies additional memory resources), can exist in the child domain of the current domain (sharing the resource and class definition of the parent domain, pay attention to the case where the class definition is replaced), or can exist directly in the current domain (also pay attention to the conflict between the class definition), such as the runtime shared library.
The application of these three methods in the code (mainly applied to, or,)
var context:LoaderContext = new LoaderContext( );
= new ApplicationDomain();//Load as child domain
= new ApplicationDomain();//Load as a brand new domain
= ;//Load the current domain
var request:URLRequest = new URLRequest("");
var loader:Loader = new Loader( );
(request, context);
5. About preloader
Preloader is a lightweight class. When the first frame of the systemManager is instantiated, the preloader will dispatch a series of events, and the progress bar monitor implements the loading interface. Once the application enters the second frame and waits for the application to be initialized, the system manager will notify the preloader initialization progress. The preloader notifies the system manager that it is ready to be deleted.
Preloader event dispatch:
progress
Indicates download progress
complete
Indicates that the download is complete
rslError
Indicates that a runtime shared library could not load
rslProgress
Indicates the download progress for a runtime shared library
rslComplete
Indicates that the download is complete for runtime shared libraries
initProgress
Indicates that the application is initializing
initComplete
Indicates that the application has initialized
In this way, preloader can be customized.
Over, faint! ~
Flex applications are fundamentally Flash applications, but they are developed based on Flex Framework (written by ActionScript). The root object of the Flex application is SystemManager (not the Application root element we see on the flex application), inherited from the -flash player display type. MovieClip is an object that supports the frame frame of the timeline basic element. In the Flex Framework, SystemManager is special, containing two frames (other components are one frame), namely preloader and the real Application. The preloader frame can be downloaded quickly and used to display the application download progress. Once the SystemManager instance of the Flex application enters the second frame, a Flex main application application instance will be created and the attribute application (null before entering the second frame). From then on, the internal life cycle and event of the application (flex main application) begins to operate:
preinitialize: The application has been instantiated but no child component has been created yet
initialize: child component has been created but layout it (lay out)
creationComplete: The application has been instantiated and the layout of all child components has been completed.
SystemManager has a topLevelSystemManager object that points to a SystemManager instance, which is the root of everything currently running in the flash player. If the flex is loaded into the flash player as the main application, the above attribute will point to itself (self-refrencing). However, when the flex application is loaded by another flex application, its own topLevelSystemManager's attribute is not self-referencing, but to its parent application's SystemManager instance. All subclasses of UIComponents have a systemManager attribute pointing to the application SystemManager instance. When the event of the component listened to by the SystemManager instance bubbles, it will have the last processing rights on the event processing chain.
2. The difference between Flash player and Framework
Flash player is the running environment of Flex applications and flash applications. The two applications have completely equal operating rights (through the API provided by Flash player). The .swf files formed by the two applications are the same in flash player. The difference is not the content of the application but their respective creation methods. Flex's Framework provides an abstraction for applications between development and operation. When compiling the Flex application, the necessary framwork library will be compiled into .swf files (also affecting the size of the application file, etc.). The main flash player class will of course not be compiled into .swf, because they already exist in the flash player, and eventually form the same flash player as the flash application can understand.
The difference between flash player class and flex framework is very convenient. The former class starts with flash, such as, while the latter starts with mx, such as
3. Dynamically load another flex application
<mx:SWFLoader source=”src/*.swf”/>
The content property of Swfloader points to the SystemManager instance of the loaded flex application (it application property points to the Application instance of the loaded felx application). When the swfloader loads and initializes the loaded flex application, it will dispatch the init event, which can be used to listen to the ApplicationComplete event of the SystemManager instance loaded flex application. When the event occurs, the Application object that loaded content can be referenced.
with inithandler (FlexEvent.APPLICATION_COMPLETE,func);
With applicationCompleteHandler...
4. Understand the application domain
An application domain (similar to the appdoamin of .net) contains class definitions, resources, etc. of flex applications. The loaded new flex application can exist in a brand new, isolated domain (occupies additional memory resources), can exist in the child domain of the current domain (sharing the resource and class definition of the parent domain, pay attention to the case where the class definition is replaced), or can exist directly in the current domain (also pay attention to the conflict between the class definition), such as the runtime shared library.
The application of these three methods in the code (mainly applied to, or,)
var context:LoaderContext = new LoaderContext( );
= new ApplicationDomain();//Load as child domain
= new ApplicationDomain();//Load as a brand new domain
= ;//Load the current domain
var request:URLRequest = new URLRequest("");
var loader:Loader = new Loader( );
(request, context);
5. About preloader
Preloader is a lightweight class. When the first frame of the systemManager is instantiated, the preloader will dispatch a series of events, and the progress bar monitor implements the loading interface. Once the application enters the second frame and waits for the application to be initialized, the system manager will notify the preloader initialization progress. The preloader notifies the system manager that it is ready to be deleted.
Preloader event dispatch:
progress
Indicates download progress
complete
Indicates that the download is complete
rslError
Indicates that a runtime shared library could not load
rslProgress
Indicates the download progress for a runtime shared library
rslComplete
Indicates that the download is complete for runtime shared libraries
initProgress
Indicates that the application is initializing
initComplete
Indicates that the application has initialized
In this way, preloader can be customized.
Over, faint! ~