In addition to cross-origin loading, you also need to add the context parameter in the loader. Load () method. The document shows that the context parameter is the loadercontext class:
Load (request: URLRequest, Context: loadercontext = NULL): void
When loading images (JPEG, GIF, or PNG) instead of SWF files, there is no need to specify a securitydomain or an application domain, because those concepts are meaningful only for SWF files. instead, you have only one demo-to make: Do you need programmatic access to the pixels of the loaded image? If so, see the checkpolicyfile property.
Therefore, the correct syntax for cross-origin loading is:
Import flash. system. loadercontext;
VaR LC: loadercontext = new loadercontext (true );
VaR Loader: loader = new loader ();
VaR request: URLRequest = new URLRequest (URL );
Loader. Load (request, LC );
Otherwise, the Flash Player Security Sandbox reports the "checkpolicyfile" error.
This oversight was found in papervision3d. When bitmapfilematerial is used, if a cross-origin image is used for texture, although crossdomain. XML is set, a sandbox error is still reported. The solution is to modify the loadnextbitmap method:
// ___________________________________________________________________________ Load next bitmap
Private function loadnextbitmap (): void
{
// Retrieve next filename in queue
Var file: String = _ waitingbitmaps [0];
VaR request: URLRequest = new URLRequest (File );
VaR LC: loadercontext = new loadercontext (true );
VaR bitmaploader: loader = new loader ();
Bitmaploader. contentloaderinfo. addeventlistener (event. Complete, loadbitmapcompletehandler );
Try
{
// Load bitmap
Bitmaploader. Load (request, LC );
// Save original URL
_ Loaderurls [bitmaploader] = file;
// Busy loading
_ Loadingidle = false;
Papervision3d. Log ("bitmapfilematerial: loading bitmap from" + file );
}
Catch (error: Error)
{
// Remove from queue
_ Waitingbitmaps. Shift ();
// Loading finished
_ Loadingidle = true;
Papervision3d. Log ("[Error] bitmapfilematerial: Unable to Load file" + error. Message );
}
}