How to use MDI Framework in Flex Code Specification
Xiaobian to share with you how to use MDI framework in Flex code specification, I hope you have gained something after reading this article, let's discuss it together!
Flex Code Specification
1. MDI Framework Use
1.1. Initialize parameter handling functions
Register window initialization event:
MessagesManager.getInstance().addEventListener(this.uid+MessageEvent.
CREATIONCOMPLETE_MESSAGE,messageHandler,false,0,true); specific reference: 4.4.5 code example;
1.2. Window Message Communication (Window Event)
◆ Message sending:
Just send the corresponding event (the type of event, usually write the module name first, then write the event type):
MessagesManager.getInstance().dispatchEvent(newEvent("moduleName_cmd"));
◆ Message reception:
Just listen for events in the window:
MessagesManager.getInstance().addEventListener("login_ok",
messageHandler,false,0,true);5.3. Release references when window closes
When the window closes, all defined references must be released, most importantly, external references held by this window and corresponding window events.
For example, write a removeHandler and put it in the removed event of the window to handle ();
/**
* Executed when removing modules
*/
privatefunctionremovedHandler(event:Event):void{ try{ if(event.target==this){//Empty all references to module definition //@TODO MessagesManager.getInstance().removeEventListener(this.uid+MessageEvent. CREATIONCOMPLETE_MESSAGE,messageHandler); } }catch(e:Error){ AlertExt.show(e.getStackTrace(),e.errorID+""); } }
2. Performance criteria in Flex code specification
2.1. deferred instantiation
For example, the navigation bar containers (ViewStack, Accordin, TabNavigator) in Flex have built-in deferred instantiation. Do not set creationPolicy="all" for controls;
2.2. MXML tag nesting levels
Minimize the number of nested containers, such as HBox, VBox, Canvas
Should be controlled within 3 layers, beyond the standard should find alternative layout scheme;
2.3. Common container redundancy to avoid
The following list provides examples of common container redundancies that should be avoided:
VBox containers in labels-Panel containers are VBox containers that support title bars, rounded edges, and other Panel styles. To lay out the child objects of a Panel as if they were in a VBox container, fill the labels of the controls directly; do not place controls in a VBox container. VBox containers are redundant packaging containers, and removing them removes another layer of unnecessary container nesting.
After reading this article, I believe you have a certain understanding of "how to use MDI framework in Flex code specification". If you want to know more about it, please pay attention to the industry information channel. Thank you for reading!