Flex 4 Gets the Swfloader embedded SWF instance

Source: Internet
Author: User

When Swfloader loads the SWF externally, everything is simple, and you can get the loaded SWF-related main class Sprite/movieclip instance directly from the content property of the Swfloader instance.


<s:swfloader id= "SWFLoader" source= "@Embed (source= ' assets/xxx.swf ')"/>

But when Swfloader is embedded in the SWF with the @embed tag as shown above, the content of the Swfloader is no longer the sprite or MovieClip represented by the SWF itself, Instead of a subclass instance of the Moviecliploaderasset class, the source code is as follows

Package Xxx.xxx{import Mx.core.moviecliploaderasset;import Flash.utils.bytearray;public class Main__embed_mxml_ assets_xxx_swf_666811031 extends Moviecliploaderasset{public function main__embed_mxml_assets_xxx_swf_666811031 () { Super (); initialwidth=11000/20;initialheight=8000/20;} private static var Bytes:bytearray = null;override Public function Get Movieclipdata (): bytearray{if (bytes = = null) {bytes = ByteArray (New DataClass ());} return bytes;} [Embed (_resolvedsource= ' x:/xxx/xxx.swf (absolute path to SWF on hard disk) ', mimetype= ' Application/octet-stream ')]public var dataclass: Class;}}

As seen above, the Moviecliploaderasset subclass instance has a public variable of class type named DataClass, and the SWF is embedded with the embed tag (as binary data ByteArray)

[Embed (_resolvedsource= ' x:/xxx/xxx.swf (absolute path to SWF on hard disk) ', mimetype= ' Application/octet-stream ')]public var dataclass: Class;

The SWF's ByteArray can be obtained through a getter named Movieclipdata.


Another Moviecliploaderasset class instance has a private loader:loader variable

private Var Loader:loader

The loader loads the embedded SWF and adds it to its display list as a unique child of the Moviecliploaderasset child class instance

That is to say SwfLoader.content.getChildAt (0) as Loader, you can get the private variable Loader,

This loader.content is the main class that embeds SWF-related Sprite/movieclip



Flex 4 Gets the Swfloader embedded SWF instance

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.