I am using flash cs 6 and as3. i am loading image from server. url is ......../....../images/باجندوح.png. am getting image when ever i enter this url in browser.but am running my code from flash builder am getting this error
"Error opening URL '..../...../images/باجندوح.png'
Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed"
.image is there in server folder .and in browser also it is loding in chrome but in mozilla and safari it is creating problem.appering ????? marks insted of arabic name. my code is :
var imgUrl:String = "...../........../images/باجندوح.png";
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(new URLRequest(imgUrl));
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, infoIOErrorEvent);
Note:image name is in arabic format..if the image name is in english it is working fine.
The problem is that the URL is not being resolved properly since there is arabic text and it's resolving to ?????.png. The solution was to encode the arabic part of the name before sending the request, and I was able to hit the image and get a successful response.
The encoding (encodeURI
) correctly resolves the URL to:
http://......./......./...../%D8%A8%D8%A7%D8%AC%D9%86%D8%AF%D9%88%D8%AD.png
Use the following code:
var imgUrl:String = "http://....../..../...../";
var imgPart:String = "باجندوح";
var finalURL:String = imgUrl + encodeURI(imgPart) + ".png";
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, infoIOErrorEvent);
loader.load(new URLRequest(finalURL));
Hope this resolves your question.