Introduction:I believe that most flexer will explore how to load code more flexibly and dynamically after writing code for a period of time. This article is to solve this problem and learn and make progress together with everyone.
Note:So far, the flex program cannot dynamically load SWC files. It can dynamically load SWF files.
Purpose:Dynamic Loading of code reduces the size of the winner program and faster download. You can flexibly load different codes as needed. Multiple relatively independent parts can be divided with little coupling. And so on
Step by step:
1. Create a new Flex project, write code, and complete the module test.
2. Create a new Flex lib project projectswc, and SRC points to the project. Build successfully. Generate projectswc. SWC as the project Lib.
3. Right-click Project-properties-Flex build path-library Path-projectSwc.swc-double-click link type-select rslmodel -generate projectswc.swf.
4.this generated projectswc.swf can be dynamically called. Condition: 1. the full path of the class must be passed in. 2 interfaces are pre-defined, such as invoke (Object: object ).
5. The call process is similar to reflection in Java. It loads SWF with loader, loads classes with getdefinition, and finally calls invoke. Complete Dynamic call.
Summary:
There may be some details in the step by step process. I hope you can explore it yourself. If you have any questions, you can come up and discuss them together.