Flash as3.0 can load external resources (images, MP3, SwF) in two ways
Source: Internet
Author: User
For external resources such as image loading in as3, I usually use two methods: loader and embed. Their respective features are summarized as follows: Embed: resources are embedded in the Flash compilation phase, that is to say, image resources will be compiled into SWF files. The advantage of this is that CodeIt is concise, easy to use, and there is no loading order problem. The disadvantage is that it increases the volume of SWF files. Loader: resources are dynamically loaded during the flash running stage. This method does not affect the volume of SWF files, in addition, you can flexibly change the resources you want to load, but you may encounter path changes or cross-domain problems. At the same time, excessive use of loader for dynamic loading will undoubtedly increase the burden on the server, therefore, we need to use the following example to weigh against embed: Embed: [embed (Source = ".. /assets/images/closebtn.png ")] private var closebtnimage: Class // image object to be embedded private var btnsprite: SPRITE = new sprite (); Private function test (): void {var BMP: bitmap = new closebtnimage (); btnsprite. addchild (BMP);} Loader: Private function additem (): void {var Loader: loader = new loader (); loader. load (New URLRequest ("http://zhufei.de/something.png"); loader. contentloaderinfo. addeventlistener (event. complete, loadcomplete);} // listens to the private function loadcomplete (E: Event): void {var L: loader+loader(e.tar get. loader); // obtain the loader object var BM: bitmap = Bitmap (L. content); // trace (l); trace (BM );}
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.