2010-02-23 25 views
0

有没有人曾经遇到过这种情况?我有crossdomain.xml集,我也尝试将本地播放设置为仅网络,仍然没有运气。AS3 URL中的禁止协议

我想要做的是让用户上传图片,然后通过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() 
+0

什么是您在phpReq上设置的网址? – Les 2010-02-23 20:37:46

+0

传递给'imgLoader.load()'的确切地址是什么?错误消息的确切文本是什么? – 2010-02-23 20:39:23

回答

2

问题就迎刃而解了。需要取出字符串的http://部分并且文件加载正常。