Using multiple SWF files

Source: Internet
Author: User

One way to reduce the size of an application's file is to break the application up into logical parts that can be sent to the client and loaded over a series of requests rather than all at once. by breaking a monolithic application into smaller applications, users can interact with your application more quickly, but possibly experience some delays while the application is running.

One approach is to use the swfloader control. this technique can work with SWF files that add graphics or animations to an application, or SWF files that act as stand-alone applications inside the main application. if you import SWF files that require a large amount of user interaction, however, consider building them as custom components. SWF files produced with earlier versions of flex or ActionScript may not work properly when loaded with the swfloader control.

Rather than loading SWF files into the main application with the swfloader control, consider having the SWF files communicate with each other as separate applications. you can do this with local export dobjects, localconnection objects, or with the externalinterface API.

Another approach to loading multiple small SWF files rather than one large one is to use the HTML wrapper to provide a framework for loading the SWF files.

 

Comparing Dynamic and Static linking

Most large applications use libraries of ActionScript classes and components. You must decide whether to use static or dynamic linking when using these libraries in your flex applications.

When you useStatic linking, The compiler dependencies des all components, classes, and their dependencies in the application SWF file when you compile the application. the result is a larger SWF file that takes longer to download but loads and runs quickly because all the code is in the SWF file. to compile your application that uses libraries and to statically link those definitions into your application, you useLibrary-PathAndInclude-librariesOptions to specify the locations of SWC files.

Dynamic LinkingIs when some classes used by an application are left in an external file that is loaded at run time. the result is a smaller SWF file size for the main application, but the application relies on external files that are loaded during run time.

To dynamically link classes and components, you compile a library. you then instruct the compiler to exclude that library's contents from the application SWF file. you must still provide link-checking at compile time even though the classes are not going to be encoded in the final SWF file.

You use Dynamic Linking by creating Component Libraries and compiling them with your application by usingExternal-library-Path,Externs, OrLoad-ExternsCompiler Options. These options instruct the compiler to exclude resources defined by their arguments from compression sion in the application, but to check links against them and prepare to load them at run time.External-library-PathOption specifies SWC files or directories for Dynamic Linking.ExternsOption specifies individual classes or symbols for Dynamic Linking.Load-ExternsOption specifies an XML file that describes which classes to use for Dynamic Linking. This XML file has the same syntax as the file produced byLink-ReportCompiler option.

For more information about linking, see about linking. For more information about compiler options, see using the flex compilers.

 

Using RSLs to reduce SWF File Size

One way to reduce the size of your application's SWF file is by externalizing shared assets into stand-alone files that can be separately downloaded and cached on the client. these shared assets are loaded by any number of applications at run time, but must be transferred only once to the client. these shared files are knownRuntime shared libraries(RSLs ).

If you have multiple applications but those applications share a core set of components or classes, your users will be required to download those assets only once as an RSL. the applications that share the assets in the RSL use the same cached RSL as the source for the libraries as long as they are in the same domain. the resulting file size for your applications can be already CED. the benefits increase as the number of applications that use the RSL increases.

When you create an RSL, be sure to optimize it prior to deployment. This removes debugging information as well as unnecessary metadata from the RSL, which can dramatically reduce its size.

For more information, see using runtime shared libraries.

 

 

 

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.