0

So I'm new at AS3 and I want my game application to consist of several SWF files to make modifications more easy. So for that I tried to load those other SWF files inside of the main one. To load each of those, I used the code below:

var loading =new Loader();
loading.load(new URLRequest('assets/loader.swf'));
ExtLoader.addChild(loading);

(ExtLoader is a movieclip on the main timeline of the main SWF.) Inside of loader.swf there is a button called 'confirm1' and I want to use it to go to another frame of the main SWF file, so I try this:

loading.content.confirm1.addEventListener(MouseEvent.CLICK, autosavewarning);

function autosavewarning(event:MouseEvent):void
{
    gotoAndPlay('AutoSaveWarning');
}

But why like that? Because I want to make sure that you cant load the application without all the external SWF files, I even thought of just loading all of them in a chain to make sure nothing is missing.

It comes up with "Error #1009: Cannot access a property or method of a null object reference." I also tried "rawContent" and "getSWFChild('confirm1')" instead of just "content" but nothing really helped. The external SWF file loads just fine, but pressing the button inside it won't do anything, is there a way for me to access it from the main file?

1
  • 1
    Possible problem №1: you are not actually waiting for the external one to load. You should listen to Event.INIT on Loader.contentLoaderInfo object and only then try to access the loaded SWF. Possible problem №2: the hierarchy is different from what you expect it to be. Fix: iterate over children on every level to learn their names, classes and ways to access them, then pick the one you want, repeat. Commented Nov 30, 2024 at 13:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.