|
Post by canfrica on Apr 18, 2009 23:45:23 GMT
I'm trying to load an external swf when a button is clicked, but the darned thing is doing nothing! (No matter how often I click, or how fast... ;P) After an animated sequence has played some buttons appear; clicking button1 loads external file "pirateAttack.swf", while clicking button2 loads "wormHole.swf", for example. Except clicking is doing no loading whatsoever. Haha. The code at present looks like this: stop();
addEventListener(Event.ADDED_TO_STAGE, init);
function init(evt:Event):void { btn_planet_gotoScene2.addEventListener(MouseEvent. CLICK, gotoScene2);
function gotoScene2(event:MouseEvent):void { var request:URLRequest=new URLRequest("scene2.swf"); var loader:Loader = new Loader(); loader.load(request); addChild(loader); } }I was getting an Error #1009 (Cannot access a property or method of a null object reference) when my button and button function code wasn't wrapped up in the addEventListener. Putting them in solved that error, but created the new problem of nothing happening when the button is clicked. Any help or pointers in the right direction would be appreciated.
|
|
|
Post by Avtar on Apr 25, 2009 20:39:04 GMT
o.O
The line : "var loader:Loader=newLoader();
Are you sure that's all right?
Shouldn't, var myLoader:Loader = new Loader(); be a better way to do it? Can you use the keyword Loader there?
|
|