I have a swf that call another swf, i use addchildAt after the preload. The first swf is center using the size of the stage, but i can do the same to the second swf. give me a error "
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at swf2_fla::MainTimeline/swf2_fla::frame1()"
I have the flas here: http://www.digisource.pt/test/flas.zip
swf1.test
I creat a mc call cub1
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
stage.align=StageAlign.TOP_LEFT;
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);
addEventListener(Event.ENTER_FRAME, resizeHandler);
var aCarregar:Loader = new Loader();
carregarSwf("swf2");
function resizeHandler(event:Event):void {
cub1.x = (stage.stageWidth/2);
}
function carregarSwf(teste:String) {
var swfACarregar:String=teste;
var swfQueCarrega:URLRequest = new URLRequest(swfACarregar+".swf");
aCarregar.load(swfQueCarrega);
aCarregar.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
aCarregar.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
}
function showPreloader(evt:Event):void {
//code to control preload
}
function showProgress(evt:ProgressEvent):void {
//math of the preload bar
}
function showLoadResult(evt:Event):void {
addChildAt(aCarregar,0);
}
in swf2.fla - i creat mc call cub2
import flash.events.Event;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
stage.align=StageAlign.TOP_LEFT;
stage.scaleMode=StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);
addEventListener(Event.ENTER_FRAME, resizeHandler);
function resizeHandler(event:Event):void {
cub2.x = (stage.stageWidth/2);
}
Please help me understand the problem
Thanks