User Guide

Loading content 467
Loading content
A SWF file can load the following types of content:
SWF files
Images
Sound
Video
Loading SWF files and images
You use the Loader class to load SWF files and images (JPG, GIF, or PNG files). Any SWF
file, other than one in the local-with-filesystem sandbox, can load SWF files and images from
any network domain. Only SWF files in local sandboxes can load SWF files and images from
the local file system. However, files in the local-with-networking sandbox can only load local
SWF files that are in the local-trusted or local-with-networking sandbox. SWF files in the
local-with-networking sandbox load local content other than SWF files (such as images),
however they cannot access data in the loaded content.
When loading a SWF file from an nontrusted source (such as a domain other than that of the
Loader object’s root SWF file), you may want to define a mask for the Loader object, to
prevent the loaded content (which is a child of the Loader object) from drawing to portions of
the Stage outside of that mask, as in the following code:
import flash.display.*;
import flash.net.URLRequest;
var rect:Shape = new Shape();
rect.graphics.beginFill(0xFFFFFF);
rect.graphics.drawRect(0, 0, 100, 100);
addChild(rect);
var ldr:Loader = new Loader();
ldr.mask = rect;
var url:String = "http://www.unknown.example.com/content.swf";
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
addChild(ldr);