아, 죄송 합니다만, 나는 당신이 이미지를로드하려하고 있다고 생각했습니다. 나는 네가 그것을 구하려고 시도하는 것을 보지 못했다. 다음과 같은 경우 모두에 대한
, 당신은 바이너리로 이미지를로드해야합니다 : 우리는 (A
Loader
사용) 일반적으로로드하는 경우, 우리는거야 무엇
var urlLoader:URLLoader = new URLLoader(new URLRequest(myURL));
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
...
이 있기 때문에 Bitmap
개체 (예 : jpg/png 데이터 자체가 아닌 이미지의 플래시 표현). 이 방법을 사용하여로드하면 ByteArray
이로드됩니다.
는 AIR를 사용하는 경우, 당신은 FileStream
클래스 사용할 수 있어야합니다 : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html
뭔가 같은 : Flash를 사용하는 경우
// NOTE: you can use any of the other File constants to get your path (e.g.
// documentsDirectory, desktopDirectory...
// myImageFileName is the name of your image, e.g. "myPic.jpg"
var file:File = File.applicationStorageDirectory.resolvePath(myImageFileName);
var fs:FileStream = new FileStream;
try
{
fs.open(file, FileMode.WRITE);
fs.writeBytes(imageBinaryData); // imageBinaryData is a ByteArray
fs.close();
}
catch (e:Error)
{
trace("Can't save image: " + e.errorID + ": " + e.name + ": " + e.message);
}
을 다음 유일한 방법은 절약 할 수 있습니다 사용자 상호 작용이없는 항목은 SharedObject
입니다. 이는 데이터가 앱 외부에서 사용 가능하지 않음을 의미합니다 (이 파일은 .sol
파일 임). 그러나 파일 조작 방법에 따라 문제가되지 않을 수도 있습니다.
// get our shared object - if you're saving a lot of images, then you might need another shared
// object, whose name you know, that stores the names of the other images
var so:SharedObject = null;
try { so = SharedObject.getLocal(this.m_name); }
catch (e:Error)
{
trace("Couldn't get shared object: " + e.errorID + ": " + e.name + ": " + e.message);
return;
}
// NOTE: it's possible you may need a registerClassAlias on the ByteArray before this
so.data["image"] = imageBinaryData;
// save the lso
try { so.flush(minDiskSpace); }
catch (e:Error)
{
trace("Couldn't save the lso: " + e.errorID + ": " + e.name + ": " + e.message);
}
실제로/당신의 SharedObject
을 얻고, 이미지에 저장된 바이너리 변환 (바이너리 모드에서) 파일을로드, 나중에 이미지를 사용하려면
var l:Loader = new Loader;
l.contentLoaderInfo.addEventListener(Event.COMPLETE, this._onConvertComplete); // you could probably also listen for the IO_ERROR event
try
{
// NOTE: you can pass a LoaderContext to the loadBytes methods
l.loadBytes(imageBinaryData);
}
catch(e:Error)
{
trace("Couldn't convert image: " + e.errorID + ": " + e.name + ": " + e.message);
}
...
// called when our loader has finished converting our image
private function _onConvertComplete(e:Event):void
{
// remove the event listeners
var loaderInfo:LoaderInfo = (e.target as LoaderInfo);
loaderInfo.removeEventListener(Event.COMPLETE, this._onConvertComplete);
// get our image
var bitmap:Bitmap = loaderInfo.content;
this.addChild(bitmap);
}
당신은 어떤을 사용할 수없는 경우 그런 다음 사용자 상호 작용 (예 : 마우스 클릭)이 있어야합니다. (호기심에서 관련 객체에 MouseEvent.CLICK
을 파견하려고 했습니까?)
어떻게 이미지를로드하나요? XML로부터 URL을 얻는다면 정상적인'Loader'가 작동 할 것입니다. 마우스 클릭 제한은 일반적으로 URL 열기 ('navigateToURL')에만 해당합니다. – divillysausages
모든 것이 YES로 작동하며, 로더이기도하지만 문제는 Btn 클릭만으로 활성화된다는 것입니다! 이것을 사용하십시오. click = "loadRemoteImage (textboxLink.text)". – aktell
'textboxLink.text'는 URL이 포함 된 레이블 일뿐입니다. 로드하는 방법은 전적으로 당신에게 달렸습니다 - 당신은 방금'click' 액션으로로드하도록 선택했습니다; 'Timer','setInterval' 또는 키보드 이벤트를 쉽게 할 수 있습니다. 그 레이블을 채웠다는 것을 알 때 그냥 호출해야합니다. – divillysausages