3 Replies Latest reply on Jun 2, 2008 9:30 PM by Gregory Lafrance

    Events question

      Hi, I'm working on a game, which is mostly complete. Right now I'm trying to make a nice loading screen so that the user doesn't think there's a bug when the game itself doesn't display right away. Most of the things in my game load quickly, except the map grid, which consists of 441 squares, each of which has four Image objects... so even after all the constructors have done their business, there's a lag of maybe 15 seconds before it actually appears on-screen.

      I want my loading screen to be displayed until the map grid is actually on-screen, and then I'll have a function called to make the loading screen disappear, activate my MouseEventListeners and so forth. I thought I could do this just by doing:


      This does leave the loading screen up for a few seconds, after which it disappears and everything goes as it's supposed to, except that the map still isn't on-screen for a few seconds thereafter. I also tried UPDATE_COMPLETE instead of CREATION_COMPLETE, but it was basically the same thing.

      Is there an event that's dispatched once an object is really, truly, actually on the screen, and not "just before" it is?
        • 1. Re: Events question
          Gregory Lafrance Level 6
          Check out the preloader docs in help system.
          • 2. Re: Events question
            Xopods Level 1
            Thanks. Your answer wasn't the solution in and of itself, but it did get me thinking more clearly about the problem.

            Instead of instantiating my map with the application's creationComplete event, which also dismisses the Preloader, I instantiated it with the application's initialize event, so now the map is on-screen before the Preloader is dismissed.

            I'm still perplexed as to why everything is on-screen when the Application's creationComplete event is dispatched, but the map dispatches its creationComplete event before it's actually on-screen... but I guess I can just accept that it works now and stop asking why.
            • 3. Re: Events question
              Gregory Lafrance Level 6
              The map dispatches its creationComplete event because it is fully created, but that does not mean it has been added to the application. The creationComplete event for the application means the application has been created, which includes adding all the other components.

              In a sense, the map does not need to be onscreen when it dispatches creationComplete, because the application itself is not yet fully valid. I guess that's why the preloader and initialize event exist, to do stuff before the app should be considered fully valid or "complete".