Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7915705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:32:50+00:00 2026-06-03T14:32:50+00:00

I’m loading multiple swf files from the main menu which is never unloaded. I’ve

  • 0

I’m loading multiple swf files from the main menu which is never unloaded. I’ve done this with the following code… Only issue is that instead of unloading to the main menu I just see a white screen as if nothing is loaded.

function BackToMenu(i:MouseEvent):void
{
    var BaseMovie:MovieClip = parent.parent as MovieClip;
    BaseMovie.parent.removeChild(BaseMovie);
}

EDIT: I’ll explain from the start I have a MainMenu.swf. The games are loaded from MainMenu.swf when the button relating to the game is clicked. When a game button is clicked on MainMenu.swf the game loads. When the player completes a game they are presented with the exit button which unloads the current game and shows the MainMenu.swf without having to re-load it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T14:32:52+00:00Added an answer on June 3, 2026 at 2:32 pm

    First, you should remove one parent to make sure you are actually removing only the game:

    function BackToMenu(i:MouseEvent):void
    {
        var BaseMovie:MovieClip = parent as MovieClip;
        BaseMovie.parent.removeChild(BaseMovie);
    }
    

    This should take care of your most pressing problem, and allow you to return to the menu. You have, however, not really unloaded the game, but only removed it from the display list. This often means, that there are still sounds running, active key and/or mouse listeners, etc. – these must all be taken care of!

    And, like I said, this will only fix your immediate problem. It is, however, neither a permanent solution, nor a good one: Since the main SWF is responsible for loading the games, it should also be responsible for disposing of them. You should put cleanup code into your game, but it should only be concerned with stopping any running scripts, sounds, etc. – simple rule: anything that is started within the game, should be stopped within the game. But it should not try to access objects further up in the display hierarchy, or try to unload itself.

    The much better way to do this is by replacing all the above code, and letting the main SWF take care of removing the game, as well as unloading it from memory. For this, you have to do three things:

    1. Instead of writing actual removeChild calls, etc., let your button dispatch a custom event to notify the main SWF that it should now be removed:

      function onBackButtonClicked( event:MouseEvent ):void {
          destroyGame(); // this would be the function that stops all the scripts
          dispatchEvent( new Event( "FINISH_GAME", true ) ); 
      }
      

      Note that “FINISH_GAME” is now a “bubbling” event, i.e. it travels downward in the display hierarchy. We can now listen for this event in any ancestor display object containing the game.

    2. In your main SWF, add an event listener to the Loader when the game was successfully loaded. This is done in the event listener that is called when the load process completes:

      function onLoadComplete( event:Event ):void {
          var loader:Loader = event.target.loader;
          loader.addEventListener( "FINISH_GAME", onFinishGame, true );
      }
      
    3. Use the corresponding event handler to remove the game clip:

      function onFinishGame( event:Event ):void {
          var loader:loader = event.currentTarget;
          loader.parent.removeChild( loader );
          loader.unloadAndStop();
      }
      

    A few more things to consider:

    • The naming conventions in ActionScript advise us to use lower case names for methods and variables, and upper case only for types.

    • The same naming conventions suggest we use either “on” or “handle” as a prefix for event listeners, along with the name of the event. Thus, it should be onBackToMenu or rather, onBackButtonClicked, etc.

    • Since I don’t know anything about the code you use for loading, I just assumed you have a complete listener, and you don’t keep references to the loader. If you use a member variable, you can use that instead of event.target, resp. event.currentTarget.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have a bunch of posts stored in text files formatted in yaml/textile (from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.