티스토리 뷰
Main.swf 는 Main.as라는 도큐먼트 클래스를 통해서 sub0.swf, sub1.swf, sub2.swf, sub3.swf 을 순차적으로 모두 로드하고
로드가 완료되면 addChild를 한다. 또한 각 sub에 있는 인스턴스(스테이지에 배치된 이름있는 인스턴스네임)도 제어해본다.
package {
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFieldAutoSize;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
[SWF(frameRate="30", width="600", height="400", backgroundColor="0x666666")]
public class Main extends Sprite{
private var _format:TextFormat;
private var _txt:TextField;
private var _ldr:Loader;
private var _idx:int;
private var _contentArr:Array = [];
public function Main() {
// constructor code
_format = new TextFormat();
_txt = new TextField();
_format.font = "돋움"
_format.size = 20;
_format.underline = true;
_txt.defaultTextFormat = _format;
_txt.autoSize = TextFieldAutoSize.LEFT;
_txt.x = 10;
_txt.y = 10;
_txt.width = 160;
_txt.height = 20;
_txt.background = true;
_txt.border = true;
_txt.selectable = false;
_txt.textColor = 0x0000FF;
_txt.text = "메인화면";
addChild(_txt);
swfLoad();
}
//sub.swf를 바로 불러와서 준비가 끝나면 addChild
private function swfLoad():void{
_ldr = new Loader();
_ldr.load(new URLRequest("sub" + _idx + ".swf"));
_ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
}
private function onComplete(e:Event):void{
var ldrMC:MovieClip = e.target.content as MovieClip;
_contentArr[_idx] = ldrMC;
_idx++;
if(_idx > 3){
build();
return;
}
swfLoad();
}
private function build():void{
var i:int = 0;
for(i=0;i<4;++i){
addChild(_contentArr[i]);
_contentArr[i].book.alpha = i+;
_contentArr[i].x = i * (120 + 15);
_contentArr[i].y = 100;
}
}
}
}
설명준비중...
결과)
'■ 플래시 ■ > Adobe ActionScript3.0' 카테고리의 다른 글
| dispatchEvent - EventDispatcher 상속을 활용한 이벤트전파 (0) | 2013.10.16 |
|---|---|
| Loader - applicationDomain.getDefinition을 이용한 라이브러리 로드 (0) | 2013.10.16 |
| cos과 rotationY의 차이점 (0) | 2013.10.16 |
| FlashPlyer 버전의 중요성 (0) | 2013.10.16 |
| hitTestObject - indexOf와 subString이용한 도형맞추기 드래그 (0) | 2013.10.16 |
댓글
Loader_-_sub.swf로드.zip