lundi 30 novembre 2015

AS3 Linking-Loading Another Swf File

i made catching game and i have the swf file. In another flash project, i want to call that swf. I created a button and wrote the codes below.

btnn.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_4);

import fl.display.ProLoader;
var fl_ProLoader_4:ProLoader;


var fl_ToLoad_4:Boolean = true;

function fl_ClickToLoadUnloadSWF_4(event:MouseEvent):void
{
    if(fl_ToLoad_4)
    {
        fl_ProLoader_4 = new ProLoader();
        fl_ProLoader_4.load(new URLRequest("CathingGame.swf"));
        addChild(fl_ProLoader_4);
    }
    else
    {
        fl_ProLoader_4.unload();
        removeChild(fl_ProLoader_4);
        fl_ProLoader_4 = null;
    }

    fl_ToLoad_4 = !fl_ToLoad_4;
}

But when i click the button, i have the error below. What could be the possible solutions? I think i have this error because in the catching game, my fla and actionscript are in different file. I mean i use external .as file. Not in the fla file.

TypeError: Error #1009: Cannot access a property or method of a null object reference. at CatchingGame()

Aucun commentaire:

Enregistrer un commentaire