2010-02-23 24 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://部分並且文件加載正常。