Adobe Flex Image控件源设置为https程序调用失败(SecurityError:错误#2122)

时间:2017-03-09 08:38:38

标签: image flex https

以下flex代码将图像控制源设置为“https程序调用”以获取图像文件并将图像数据克隆到位图中,然后将其作为子图像添加到另一个图像查看器中:

    <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'实际上会返回一个字符串'https://fs.mysite.com/img/mylogo.jpg'。

我在ap.mysite.com上的crossdomain.xml中设置了策略:

<allow-access-from domain="ap.mysite.com" secure="false" />

在ap.mysite.com上,我写了一个jsp来包含这个swf并在浏览器上运行它,它只显示“load ok”但从不“克隆ok”并且异常显示

  

error = SecurityError:错误#2122

如果我直接

_imageURL = https://fs.mysite.com/img/mylogo.jpg

然后将显示“clone ok”。

我认为问题是图像控制源不接受程序调用但是当我将https更改为该程序调用字符串的http时,它运行良好。

有些人告诉我“loadPolicyFile”和“allowDomain”,但我不知道。我做错了什么或我错过了什么?

1 个答案:

答案 0 :(得分:1)

添加以下代码,它将起作用

Security.loadPolicyFile("yoursite/crossdomain.xml");
相关问题