2017-02-26 4 views
0

웹 링크를 통해 이미지를 표시하는 AS3 코드에 UIloader가 있습니다. 사용자 일단 인터넷 연결없이 이미지를로드하려면 AS3의 UILoader에로드 된 이미지를 저장하십시오.

uiloader1.source = "http://www.mywebsite/image1.jpg"; 
uiloader2.source = "http://www.mywebsite/image2.jpg"; 

는 인터넷 연결 응용 프로그램을 열어, 나는 그 어떤 인터넷 연결없이 다시 열 수 있기를 여전히 이미지를 표시 할 수있을 것입니다.

내가 좋아하는 뭔가에 대해 생각 :

var savedImage:SharedObject; 
savedImage= SharedObject.getLocal("ImagesFolder"); 

if (monitor.available || savedImage.data.images == "null") { 

    uiloader1.source = "http://www.mywebsite/image1.jpg"; 
    uiloader2.source = "http://www.mywebsite/image2.jpg"; 

    savedImage.data.loader1 = uiloader1.source; 
    savedImage.data.loader2 = uiloader2.source; 

} 

else { 

    uiloader1.source = savedImage.data.loader1; 
    uiloader2.source = savedImage.data.loader2; 

} 

그러나이 이미지의 링크가 아닌 실제 이미지를 저장으로 작동하지 않습니다.

이미지를 파일로 저장하고 및 uiloader2.source에로드하는 방법을 알려주세요.

uiloader10.source = "http://www.myWebsite/image1.jpg"; 
uiloader10.addEventListener(Event.COMPLETE, completeHandler); 

function completeHandler(event:Event):void { 

    var bitmapData:BitmapData = new BitmapData(uiloader10.width,uiloader10.height); 
    bitmapData.draw(uiloader10); 
    var jpgencoder:JPGEncoder = new JPGEncoder(100); 
    var mybyte:ByteArray = jpgencoder.encode(bitmapData); 
    var myfile:FileReference = new FileReference(); 

    myfile.save(mybyte,"test.jpg"); 

} 

작동 (아직 내 전화 장치에서, 바탕 화면에서 테스트)하는 것 같다

편집 그래서 나는 것을 시도했습니다.

1 /하지만 당신은 내가 AIR 응용 프로그램에 대해 그렇게해서는 안된다고 생각합니까? '앱 호환성'을 높이기 위해 변경해야하는 코드를 알려주세요.

2/어떻게 자동으로 경로를 검색 할 수있는 방법하여 UILoader에서 파일을 (로드합니까 " 예 : 물론 Unhandled ioError:. text=Error #2035: URL Not Found. URL: app:/test.jpg

+0

1. 당신이 게시하는 경우 ** AIR ** - AIR는 **, 그것은 더 많은 기능을 가지고 **에 대한 이동합니다. 그리고 약간의 노력이 있었나요? Google> 저장 파일> 첫 번째 링크. 2. 그런 다음 파일 URL은 "app : /test.jpg"가 아니며 저장 한 위치를 알지 못합니다. 아마 당신은 ** FileReference.name ** (파일을 저장 한 후 무엇입니까?)와 ** File.applicationDirectory.nativePath **를 비교해야합니다. – Organis

답변