Adobe Flex Image control source set to https program call fails (SecurityError: Error #2122)
Adobe Flex Image control source set to https program call fails (SecurityError: Error #2122)
以下 flex 代码将图像控制源设置为 'a https program call' 以获取图像文件并将图像数据克隆到位图中,然后将其作为子项添加到另一个图像查看器:
<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'.
我在 crossdomain.xml 中设置了 ap.mysite.com 政策:
<allow-access-from domain="ap.mysite.com" secure="false" />
在 ap.mysite.com 上,我写了一个 jsp 来包含这个 swf 和 运行 它在浏览器上,它只显示 "load ok" 但从不显示 "clone ok" 和异常显示
error=SecurityError: Error #2122
如果我直接se
_imageURL = https://fs.mysite.com/img/mylogo.jpg
然后会显示"clone ok"。
我认为问题是图像控制源不接受程序调用,但是当我将那个程序调用字符串的 https 更改为 http 时,它工作正常。
有些人告诉我 "loadPolicyFile" 和 "allowDomain" 但我不认识他们。我做错了什么或错过了什么?
添加下面的代码就可以了
Security.loadPolicyFile("yoursite/crossdomain.xml");
以下 flex 代码将图像控制源设置为 'a https program call' 以获取图像文件并将图像数据克隆到位图中,然后将其作为子项添加到另一个图像查看器:
<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'.
我在 crossdomain.xml 中设置了 ap.mysite.com 政策:
<allow-access-from domain="ap.mysite.com" secure="false" />
在 ap.mysite.com 上,我写了一个 jsp 来包含这个 swf 和 运行 它在浏览器上,它只显示 "load ok" 但从不显示 "clone ok" 和异常显示
error=SecurityError: Error #2122
如果我直接se
_imageURL = https://fs.mysite.com/img/mylogo.jpg
然后会显示"clone ok"。
我认为问题是图像控制源不接受程序调用,但是当我将那个程序调用字符串的 https 更改为 http 时,它工作正常。
有些人告诉我 "loadPolicyFile" 和 "allowDomain" 但我不认识他们。我做错了什么或错过了什么?
添加下面的代码就可以了
Security.loadPolicyFile("yoursite/crossdomain.xml");