PDA

View Full Version : AS3 Loading


three_suns
07-28-2008, 06:15 PM
Greeting to all!

I learning OOP in AS3 and came across something that has me bound!

I am trying to load a external movieclip on to the stage from a movieclip. I am not getting any error but the file is not loading on to the stage. I have been getting the following message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.


The following is the script that I have inside the movieclip:

test1_btn.addEventListener(MouseEvent.CLICK, myButtonFunction);
function myButtonFunction(event: MouseEvent) {
var request:URLRequest = new URLRequest("happy.swf");
var loader:Loader = new Loader();
addChild(loader);
}


Am I missing something?

gnomeontherun
07-29-2008, 05:16 AM
I'm not 100% because I don't know AS3, but I think you might have to put the code on the main timeline instead of inside the movieclip?