Flex calls the method in SWF

Source: Internet
Author: User

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

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
  3. <Mx: SCRIPT>
  4. <! -- [CDATA [
  5. Public Function sayhello (): void {
  6. Trace ("helloworld from mxml ");
  7. }
  8. ] -->
  9. </MX: SCRIPT>
  10. </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

    1. Package {
    2. Public class hellowworld2 {
    3. Public Function sayhello (): void {
    4. Trace ("Helloworld from ");
    5. }
    6. }
    7. }

Package {public class hellowworld2 {public function sayhello (): void {trace ("helloworld from ");}}} 

App. mxml

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <Mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute">
  3. <Mx: SCRIPT>
  4. <! -- [CDATA [
  5. Public Function completehandler1 (EVT: Event): void {
  6. Object(evt.tar get. content. Application). sayhello ();
  7. }
  8. Public Function completehandler1 (EVT: Event): void {
  9. Object(evt.tar get. Content). sayhello ();
  10. }
  11. ] -->
  12. </MX: SCRIPT>
  13. <Swfloader id = "hw1" Source = "helloworld1.swf" complete = "completehandler1 (event)"/>
  14. <Swfloader id = "hw2" Source = "helloworld2.swf" complete = "completehandler2 (event)"/>
  15. </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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.