I'd avoid loading foreign content as the backgroundImage.  If that server goes 
down, your app will look very different.
If you really want to, then it might be easier to put an Image behind all of 
the other children and not use backgroundImage

Alex Harui
Flex SDK Developer
Adobe Systems Inc.<http://www.adobe.com/>
Blog: http://blogs.adobe.com/aharui

From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf 
Of rdibona
Sent: Friday, March 13, 2009 11:15 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] canvas backgroundimage loadercontext


Hi there,

I have an application where I take a "snapshot" of a Canvas with various other 
images on it using the bitmapdata.draw method. I had to change my code to use a 
LoaderContext for each image load to avoid security errors, i.e.:

var lc : LoaderContext;
var img : Image;

img = new Image();
lc = new LoaderContext(true);
img.loaderContext = lc;
img.load(src);

This has worked fine. However, I cannot figure out how to avoid a security 
error when setting the backgroundImage style for a canvas, as it expects a URL 
directly with no opportunity to specify another image as the value. It does say 
you can specify a class, but how do you cast an image into a compatible class? 
The images I am dealing with are dynamically loaded at run-time so there is no 
opportunity to use the Embed directive.

Thanks,

Rich

Reply via email to