Generally, three types of SwF are generated: one is the compilation of the Flex mxml main application, and the other is the compilation of the as class using the flex SDK, another reason is that FLA runs and generates data in Flash cs3.
Because 3rd call methods are the same as 2nd, the first two SWF applications in the flex project are described here.
Helloworld1.mxml
-
- <? XML version = "1.0" encoding = "UTF-8"?>
-
- <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
-
- <Mx: SCRIPT>
-
- <! -- [CDATA [
-
- Public Function sayhello (): void {
- Trace ("helloworld from mxml ");
-
- }
-
- ] -->
-
- </MX: SCRIPT>
-
- </MX: Application>
<? XML version = "1.0" encoding = "UTF-8"?> <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute"> <mx: SCRIPT> <! -- [CDATA [Public Function sayhello (): void {trace ("helloworld from mxml") ;}] --> </MX: SCRIPT> </MX: Application>
Helloworld2.as
- Package {
- Public class hellowworld2 {
- Public Function sayhello (): void {
- Trace ("Helloworld from ");
- }
- }
- }
Package {public class hellowworld2 {public function sayhello (): void {trace ("helloworld from ");}}}
App. mxml
-
- <? XML version = "1.0" encoding = "UTF-8"?>
- <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
-
- <Mx: SCRIPT>
-
- <! -- [CDATA [
-
- Public Function completehandler1 (EVT: Event): void {
-
- Object(evt.tar get. content. Application). sayhello ();
-
- }
- Public Function completehandler1 (EVT: Event): void {
-
- Object(evt.tar get. Content). sayhello ();
-
- }
-
- ] -->
-
- </MX: SCRIPT>
-
- <Swfloader id = "hw1" Source = "helloworld1.swf" complete = "completehandler1 (event)"/>
-
- <Swfloader id = "hw2" Source = "helloworld2.swf" complete = "completehandler2 (event)"/>
- </MX: Application>
<? XML version = "1.0" encoding = "UTF-8"?> <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute"> <mx: SCRIPT> <! -- [CDATA [Public Function completehandler1 (EVT: Event): void {object(evt.tar get. content. application ). sayhello ();} public function completehandler1 (EVT: Event): void {object(evt.tar get. content ). sayhello () ;}]] --> </MX: SCRIPT> <swfloader id = "hw1" Source = "helloworld1.swf" complete = "completehandler1 (Event) "/> <swfloader id =" hw2 "Source =" helloworld2.swf "complete =" completehandler2 (event) "/> </MX: Application>
Helloworld1.mxml and helloworld2.as are compiled into SWF using the flex SDK respectively, and then debugged in APP. mxml.
It can be seen that the first type of situation generated by swfis generated by using mxml. e.tar get. Content is actually a systemmanager class object, which must be accessed directly by using get. content.