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

  • Home
  • SEARCH
  • 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 8379909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:18:51+00:00 2026-06-09T16:18:51+00:00

I have a game that I’ve made that runs in two files, one the

  • 0

I have a game that I’ve made that runs in two files, one the preloader and one the swf. When I use these two files together they work fine, however some flash portals require only one SWF, so I’m trying to find the shortest-path way to convert it to use only one.

The game swf uses a Document Class that includes the package, class constructor, and tons of functions, and runs fine. I have lots of movieclips on the stage that I refer to in my code. The code is something like this (abridged):

package  {

    import flash.display.MovieClip;
    import flash.events.MouseEvent;
...
    public class Game extends MovieClip {       
    var EnemyArray:Array;
    var HeroArray:Array;
...
public function Game() { // class constructor
        EnemyArray = new Array();
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
                    mainRestartButton.addEventListener(MouseEvent.CLICK, RestartLevel);
...
}
public function KeyPressed(event:KeyboardEvent):void
    {
        if (event.keyCode == Keyboard.SPACE)
        {
        attack();
...
            }
} // End of class
} // End of package

I also have another swf, my preloader, which has the following code in frame 1:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
import flash.events.Event;

var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
var myURL:URLRequest = new URLRequest("Game.swf");
myLoader.load(myURL);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onLoading(event:ProgressEvent):void {
    var loaded:Number = event.bytesLoaded / event.bytesTotal; 
    percent_txt.text = "Loading: " + (loaded*100).toFixed(0) + "%";

}

function onComplete(event:Event):void { 
    myLoader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoading);
    myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
    this.addChild(myLoader);
}

I’ve been through the gamut of solutions online and none of them seem to work with the way that my code is set up, such as: How to create Preloader in AS3

I tried his option 1 by taking all the code in my Document Class other than the package and constructor and pasted it into frame 2. However it returns “Error #1009: Cannot access a property or method of a null object reference.” for any references to items on the stage, such as:

  mainRestartButton.addEventListener(MouseEvent.CLICK, RestartLevel);

As he mentions, “This works well if you organized your project in a way that the most of the assets (images, etc) are in the Flash IDE Library and are not loaded on the first frame (you can check that in each library item’s properties).” My project is NOT organized in such a way.

What is the easiest way for me to reorganize my FLA/code so they can have a preloader in a single swf?

Thanks so much for your time and help!

  • 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-09T16:18:53+00:00Added an answer on June 9, 2026 at 4:18 pm

    I use FlashDevelop (no FLAs) so I’m not sure if it’ll work for you but I use the solution described here.

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

Sidebar

Related Questions

I have 5 game sections that will use the same template sheet, but they
I have an OpenGL ES game that I am hacking together. One part of
I have a game that currently runs under Windows and Mac OS X and
I have a cocos2d powered game that uses UIKit menues, so I only use
I have a game that one player X wants to pass a ball to
I have very recently started development on a multiplayer browser game that will use
I have a facebook application (a two player game) that can post messages on
i have a game that contain two viewcontroller, when the user end the game
I have a game that I have made in C# and it installs and
I have a silly little game that I made just for myself, but I

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.