URL中的AS3禁止协议

时间:2010-02-23 20:31:09

标签: flash actionscript-3 flash-cs3

以前有没有人碰到这个?我有crossdomain.xml设置,我也尝试将本地播放设置为仅网络,但仍然没有运气。

我要做的是让用户上传图片,然后我通过PHP传递该值并创建一个目录。之后,它返回路径,我尝试将图像作为缩略图加载,这就是我遇到安全错误。

//frOne is my fileReference variable.
function oneSelected(e:Event)
{
    trace("\nName: " + e.target.name);
    trace("\nSize: " + e.target.size);
    frOne.upload(uploadURL);
    getImage(frOne.name);
}
function getImage(imgName:String)
{
    phpVars.imagename = imgName;
    phpReq.data = phpVars;
    phpLoader.addEventListener(Event.COMPLETE, phpImage);
    phpLoader.dataFormat = URLLoaderDataFormat.TEXT;
    phpLoader.load(phpReq);
    phpReq2.method = URLRequestMethod.POST;
    trace('send the info');
}

function phpImage(e:Event)
{
    testString = phpLoader2.data;
    var decoded:String = decodeURI(testString);
    testString  = decoded;
    var imgLoader:Loader = new Loader();
    imgLoader.load(new URLRequest(testString.slice(0,testString.length) + frOne.name));
    addChild(imgLoader);
}

我得到的错误

http://url/bwljagvsbgv6enjhdghlcnl5ymniz3p6y29t/images/Winter.jpg

*** Security Sandbox Violation ***
Connection to 

http://url/bwljagvsbgv6enjhdghlcnl5ymniz3p6y29t/images/Winter.jpg 
halted - not permitted from file:///Z|/mydirectory/myswf.swf

SecurityError: Error #2147: Forbidden protocol in URL 

http://url/bwljagvsbgv6enjhdghlcnl5ymniz3p6y29t/images/Winter.jpg.
    at flash.display::Loader/flash.display:Loader::_load()
    at flash.display::Loader/load()
    at BCBGen_fla::MainTimeline/loadImage()
    at BCBGen_fla::MainTimeline/fnImageTimer()
    at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
    at flash.utils::Timer/flash.utils:Timer::tick()

1 个答案:

答案 0 :(得分:2)

问题解决了。需要取出字符串的http://部分并加载文件。