2010-02-23 2 views
0

이미지를로드하고 표시하려면 갤러리를 만들어야합니다. 이 부분은 괜찮습니다 :이미지가 플렉스 로딩되는 동안 로더 이미지 추가

/**  
* @variable image_name to store the name of the selected item 
*/  
private function showimage(evt:Event):void 
{ 
    // to store the name of the selected image 
    var image_name : String = evt.currentTarget.selectedItem.img_name; 

    // checks if any item is clicked 
    try 
    { 
     if(image_name == "") 
     { 
      throw new Error("No image selected from the list"); 
     } 

     // supplying the image source for the Image imgmain 
     // also supplying the height and width for the image source 
     imgMain.source = siteurl + image_name.toString(); 

    } 
    catch(err:Error) 
    { 
     Alert.show(err.message); 
    } 
} 

여기서 imgMain은 이미지 구성 요소의 ID입니다.

하지만 작은 꼬임이 필요합니다. 이미지가 로딩되는 동안, 천이 이미지, 즉 로딩 이미지가 디스플레이되어야한다. Plz 나를 도와주세요.

답변

0

이것은 매우 쉽게 달성 할 수 있습니다. 나는이 방법으로 그것에 대해 제안 할 것입니다. 로딩 이미지의 'imageHolder'스프라이트를 생성하고 표시 목록에 추가하십시오. loader.contentLoaderInfo에서 Event.INIT에 대한 리스너를 추가하면로드가 완료되면로드중인 이미지가 제거되고 imageHolder에 loader.content가 추가됩니다.

var _imageHolder:Sprite = new Sprite(); 
addChild(_imageHolder); 

// add your loading image to the _imageHolder 
_imageHolder.addChild(new LoadingImage()); // exported in your library? 

var _loader:Loader = new Loader(); 
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onLoadComplete); 
_loader.load(new URLRequest('path to assset')); 

// image has loaded so remove the display image and add the content 
function _onLoadComplete(e:Event):void{ 
    _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, _onLoadComplete); 
    _imageHolder.removeChildAt(0); 
    _imageHolder.addChild(_loader.content); 
} 
관련 문제