로드하려는 각 이미지마다 별도의 로더를 사용합니다. 여기에 구현할 수있는 방법에 대한 간단한 예가 있습니다 :
* 편집 : 패키지 부분을 자르고 있습니다. stackoverflow의 코드 파서를 이해하지 못해서 용서해주십시오. *
`package
{ import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.net.URLRequest;
public class LoaderTest extends Sprite
{
//two loaders
private var _firstLoader:Loader = new Loader();
private var _secondLoader:Loader = new Loader();
//just assuming you already have the buttons you want setup, use these as theoretical buttons
private var _buttonOne:Sprite;
private var _buttonTwo:Sprite;
public function LoaderTest()
{
_firstLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
_secondLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
_firstLoader.load(new URLRequest("path/to/image.jpg"));
_secondLoader.load(new URLRequest("path/to/image.jpg"));
_buttonOne.addEventListener(MouseEvent.CLICK, showImage);
_buttonTwo.addEventListener(MouseEvent.CLICK, showImage);
}
private function imageLoaded(e:Event):void
{
//do something if you want
}
private function showImage(e:MouseEvent):void
{
switch(e.target)
{
case _buttonOne :
if (!contains(_firstLoader))
{
if (contains(_secondLoader))
removeChild(_secondLoader);
addChild(_firstLoader);
}
break;
case _buttonTwo :
if (!contains(_secondLoader))
{
if (contains(_firstLoader))
removeChild(_firstLoader);
addChild(_secondLoader);
}
break;
}
}
}
은} `
당신은 몇 가지 코드를 보일 수 있는가? – bhups