0
votes

I have a problem ! I have two SWF. One with the game that we created and an other one with the MainMenu of the game.

I want to load the SWF of the game when I Click on play on the MainMenu. I add this code on the first frame of the MainMenu :

btnJouer.addEventListener(MouseEvent.CLICK,jouer);

function jouer(pEvt:MouseEvent){
    var request:URLRequest = new URLRequest("testMouvement.swf"); 
    var loader:Loader = new Loader() 
    loader.load(request); 
    Security.allowDomain(loader.contentLoaderInfo.url);
    addChild(loader);
}

But when I click on play I hear the sound of my game but the game don't appear..

I have some error when I click on play but I don't understand .. If I load the swf of the game without the mainmenu everything work fine..

The Error when I click on play :

*TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
    at cem::saut()[C:\Users\1124889\Desktop\Prog3.2\cem\saut.as:58]
    at hero()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at cem::application()[C:\Users\1124889\Desktop\Prog3.2\cem\application.as:69]
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
    at cem::saut2()[C:\Users\1124889\Desktop\Prog3.2\cem\saut2.as:52]
    at hero2()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at cem::application()[C:\Users\1124889\Desktop\Prog3.2\cem\application.as:69]
TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
    at cem::application()[C:\Users\1124889\Desktop\Prog3.2\cem\application.as:70]*

Sorry for my english am french. Thank you if someone can help me !

1

1 Answers

0
votes

I can't comment so I'll just answer here.

If you want to load external SWF into your own SWF, you'll need to use SWFLoader

I've answered more thoroughly here: Actionscript 3 - List error when loading another a swf in my swf