Hello
Only recently started aquainting myself with AS3 and have created a basic fla. with 2 buttons. One to load a swf with xml in it which animates onto the stage in my main fla. The second button is just supposed to play the rest of the loaded swf so it animates off, then unloads the loader. Here’s my code.
unloadbutton.mouseEnabled=false; //Cancel button is unavailable until the load button is pressed
/////////////////////////////////////////////// Load Button /////////////////////////////////////////////////////////////
loadbutton.addEventListener(MouseEvent.MOUSE_OVER, mouseoverload);
loadbutton.addEventListener(MouseEvent.MOUSE_OUT, mouseoutload);
loadbutton.addEventListener(MouseEvent.MOUSE_DOWN, mouseclickload);
function mouseoverload(event:MouseEvent):void {
loadbutton.gotoAndStop(2);
}
function mouseoutload(event:MouseEvent):void {
loadbutton.gotoAndStop(1);
}
var loader:Loader = new Loader();
function mouseclickload(event:MouseEvent):void{
loadbutton.gotoAndPlay(3);
addChild(loader);
var swfloader:URLRequest=new URLRequest('XML animated in swf.swf');
loader.load(swfloader);
unloadbutton.mouseEnabled=true;
}
//////////////////////////////////////// Cancel Button /////////////////////////////////////////////////
unloadbutton.addEventListener(MouseEvent.MOUSE_OVER, mouseover);
unloadbutton.addEventListener(MouseEvent.MOUSE_OUT, mouseout);
unloadbutton.addEventListener(MouseEvent.MOUSE_DOWN, mouseclick);
function mouseover(event:MouseEvent):void {
unloadbutton.gotoAndStop(2);
}
function mouseout(event:MouseEvent):void {
unloadbutton.gotoAndStop(1);
}
var loadedswf:MovieClip = loader.content as MovieClip;
function mouseclick(event:MouseEvent):void {
unloadbutton.gotoAndPlay(3);
loadedswf.gotoAndPlay(16);
loadedswf.addEventListener(Event.COMPLETE, swfanimatedout);
function swfanimatedout(e:Event):void {
loader.unload(); //I'm hoping this function will mean the 'loadedswf' will have time to animate offscreen before it is unloaded. I tested the code without this function in and still the same result
}
loadbutton.mouseEnabled=true;
}
This code brings up the error ‘TypeError: Error #1009: Cannot access a property or method of a null object reference. at XMLWIthinSWFloadengine_fla::MainTimeline/mouseclick()’
I’ve no idea what it means or what I’m to do about it.
Any help appreciated.