ActionScript 3 external SWF file loading

Source: Internet
Author: User
Tags addchild
Intend to start into the development of AS3, the previous AS2 code will gradually shift over, in the coding process may get some valuable information, I will share and discuss with you. There are better suggestions that can be made here. I do not guarantee that the method I am using is the best, nor does it guarantee that the code has no problems, and that, in this way, I am not responsible for any problems arising from the use of my Code. Also, please note that you do not use this code for commercial purposes, and if necessary, please contact me.

Loading external SWF files in AS2 generally uses Moviecliploader objects, and in AS3 it is more convenient to use loader. Loader inherits Displayobject, so you can load it directly into a displayobject using the Addchild method:

var loader:loader = new Loader ();
This.addchild (loader);

But then you load in a loader instead of loader object load in the SWF, so you need to take this way:

var loader:loader = new Loader ();
Loader.contentLoaderInfo.addEventListener (Event.complete, Completehandler);
Loader.load (New URLRequest ("lib.swf"));
function Completehandler (event:event) {
var _content:displayobject = event.target.content;
This.addchild (loader);
}

Also, be aware that you can't listen directly to the loader object to get the file loaded. Need to adopt loader.contentloaderinfo.

Point

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.