The following flex codes set image control source as 'a https program call' to get a image file and clone image data into a bitmap, then add it as child to another image viewer:
<ns1:ImageViewer id="imageViewer" bitmapScaleFactorMax="5" bitmapScaleFactorMin=".05"width="100%" height="100%" x="0" y="0" />
<mx:Image id="navImage" source="{_imageURL}" complete="{loadOK()}" />
private function loadOK():void
{
Alert.show("load ok");
try {
preImageData = (navImage.content as Bitmap).bitmapData.clone();
Alert.show("clone ok");
} catch (err:Error) {
Alert.show"error="+err);
}
preImage = new Bitmap(preImageData);
Alert.show("bitmap ok");
preImage.scaleX /= scaleRatio;
preImage.scaleY /= scaleRatio;
imageViewer.addChildAt(preImage, 0);
Alert.show("cloned navImage add to imageBiewer ok");
// some further codes
}
public function appStart():void
{
_imageURL = "https://fs.mysite.com/getimgurl.jsp?pic=logo";
}
'https://fs.mysite.com/getimgurl.jsp?pic=logo' actually returns a string 'https://fs.mysite.com/img/mylogo.jpg'.
I've set policy in crossdomain.xml on ap.mysite.com:
<allow-access-from domain="ap.mysite.com" secure="false" />
On ap.mysite.com, I write a jsp to include this swf and run it on browser, it only displays "load ok" but never "clone ok" and the exception shows
error=SecurityError: Error #2122
If I directly se
_imageURL = https://fs.mysite.com/img/mylogo.jpg
then "clone ok" will be displayed.
I thought the problem is that image control source doesn't accept program call but when I change https to http of that program call string, it works well.
Some people tell me about "loadPolicyFile" and "allowDomain" but I don't know them. What do I do wrong or what do I miss?
add the following code and it will work
Security.loadPolicyFile("yoursite/crossdomain.xml");