2012-06-28 1 views
8

순차 JPEG 형식 (http://en.wikipedia.org/wiki/JPEG#JPEG_compression, 순차 JPEG의 점진적 디스플레이와 혼동하지 말 것)으로 이미지를 표시해야합니다. Flash는 점진적 JPEG로드를 지원하지만로드하는 동안이를 표시하는 방법을 알지 못합니다. 간략한 인터넷 검색을 사용하면 순차적 JPEG를 점진적으로로드하고 그 밖의 것은 없습니다.로딩 중에 점진적인 JPEG을 플래시에 표시하십시오.

+0

여기에 묻는대로 의미합니까? http://stackoverflow.com/questions/1814833/how-to-dynamically-load-a-progressive-jpeg-jpg-in-actionscrip-3-using-flash-and –

답변

4

그것은 이런 식으로 뭔가를 갈 것 다음 같이 loadBytes 프로세스가 비동기

// the loader containing the image 
var loading:Boolean = false; 
var loader:Loader = new Loader(); 
addChild(loader); 
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function() { 
    loading = false; 
    trace(loader.width, loader.height); 
}); 

var bytes:ByteArray = new ByteArray(); 

var stream:URLStream = new URLStream(); 
stream.addEventListener(ProgressEvent.PROGRESS, onProgress); 
stream.addEventListener(Event.COMPLETE, onProgress); 
stream.load(new URLRequest(imageURL)); 

function onProgress(e:Event):void { 
    stream.readBytes(bytes, bytes.length); 
    if((bytes.length > 4096 && !loading) || e.type == Event.COMPLETE) { 
     loading = true; 
     loader.loadBytes(bytes); 
    } 
} 

공지있다. 또한 처리 할 수없는 bytearray (보통 onProgress에 대한 첫 번째 호출, 처리 할 이미지 데이터가 충분하지 않을 때)를 시도하면 자동으로 실패하므로 충분한 데이터가 있음을 보장해야합니다.이 경우에는 if (bytes.length> 4096);)

+0

솔루션은 이미지를로드하지만 이미지를로드하지 못합니다. 실제 크기. – Pehat

+0

loader.contentLoaderInfo의 첫 번째 완료 이벤트에서 이미지 크기를 가져올 수 있어야합니다. – Cay

관련 문제