7 Replies Latest reply on Jul 10, 2007 6:01 AM by paperworld

    ResourceManager won't instantiate...

    paperworld
      I've just started using the Flex 3 Beta and have been particularly interested in trying out the runtime localisation features. But when trying to create even a simple UI component i'm getting given the following error.

      TypeError: Error #1007: Instantiation attempted on a non-constructor.
      at mx.resources::ResourceManager$/getInstance()

      i get the same thing if i try and grab a reference to the ResourceManager instance via ResourceManager.getInstance();

      Am i doing something really stupid here or is this something wrong with my installation.
        • 1. Re: ResourceManager won't instantiate...
          Ivascu Cristian Level 1
          Hello,

          I did not manage to reproduce this behavior. If possible post the code that triggers the error or file a bug here and anay relevant details of your installation - e.g. OS, language settings, flash player version.

          Thanks,
          Cristian Ivascu
          • 2. Re: ResourceManager won't instantiate...
            paperworld Level 1
            Well, the code's fairly spread out right now - but basically i created a new Flex Library Project and in one of the classes in there i just created a new Label -

            message = new Label();

            the debug from the player is telling me it gets as far as the method in which the label is created, then the label is created and UIComponent gets instantiated and then it fails when it gets to creating the resource manager.

            i'm on a PC running XP pro...
            • 3. Re: ResourceManager won't instantiate...
              paperworld Level 1
              here's the full error

              TypeError: Error #1007: Instantiation attempted on a non-constructor.
              at mx.resources::ResourceManager$/getInstance()
              at mx.core::UIComponent()
              at mx.controls::Label()
              at com.paperworld.registration::RegistrationView/private::createBackground()
              at com.paperworld.registration::RegistrationView()
              at com.paperworld.registration::Registration/private::createRegistration()
              at com.paperworld.registration::Registration/main()
              at com.paperworld.application::Application/initialiseRegistration()
              at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at com.paperworld.application.loading::GameLoader/allFilesLoaded()
              at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
              at flash.events::EventDispatcher/dispatchEvent()
              at com.paperworld.preload::LoaderQueue/completeHandler()
              at [execute-queued]
              • 4. Re: ResourceManager won't instantiate...
                GordonSmith Level 4
                The getInstance() method of ResourceManager relies on the ResourceManager having been already registered with the Singleton class, which happens during application startup. This runtime error would occur if you tried to create a Label so early in the application startup sequence that the ResourceManager hadn't been registered yet with Singleton. I see on your callstack that the calling method is completeHandler() in your LoaderQueue class. Can you explain when this executes?
                • 5. Re: ResourceManager won't instantiate...
                  paperworld Level 1
                  thanks for your reply, Gordon.

                  The flow is like this:

                  I have a library project called Application that loads a config XML file that basically lists all the files for various modules that the application needs to function.

                  So the app is fired by an actionscript class that calls Application.getInstance().initialise() - this instantiates the Applciation class which in turn instantiates the class that loads the config file and parses it... it runs through the modules defined in the xml and adds each file request to a custom LoaderQueue which creates either a Loader or URLloader, depending on file type which starts to load all of the required files.

                  When all of the files are loaded it looks to see if a user has a valid chatname defined - if not it loads the Registration module so a user can register.

                  So the call to create a label is happening after the Application class has instantiated, the ApplicationInitialiser has instantiated and loaded an xml file, parsed it, created a LoaderQueue and added a group of file requests to it, all these files have loaded (currently about 4 or 5, but will eventually be a couple of dozen) and then started up the Registration module - who's 'view' is creating the label... so it's early in the application itself but quite a lot has happened before i start trying to create UIComponents. Incidentally, the skin file for the Registration module is loaded and attached to the display list before the label is created, that happens ok, but then the label won't instantiate.

                  At what point does the ResourceManager register? This is a purely actionscript project so it occured to me after i've posted that cause i'm not using any mxml components that this could be a big part of the problem.. is that the case? If you want a copy of the code i'm using to recreate this issue then just ask and give me an email address to send it to...

                  Again, thanks for the reply...

                  T
                  • 6. Re: ResourceManager won't instantiate...
                    GordonSmith Level 4
                    > At what point does the ResourceManager register?

                    The SystemManager's initialize() method registers the ResourceManager with the Singleton class.

                    > This is a purely actionscript project so it occured to me after i've posted that cause i'm not using any mxml components that this could be a big part of the problem.. is that the case?

                    Quite possibly. It sounds like the SystemManager isn't even part of your app. FlexBuilder's "ActionScript Project" is for people who don't want to use any Flex framework components and instead write to the low-level player APIs like Sprite. Since you're using Flex components, you should be starting off with <mx:Application>. Everything else can be an ActionScript component rather than an MXML one, but your top-level file should be in MXML. I'm surprised you're not having all sorts of other problems (for example, with missing style selectors) if you're not doing this.
                    • 7. Re: ResourceManager won't instantiate...
                      paperworld Level 1
                      thanks Gordon, how incredibly embarrasing! :)

                      i've been working in actionscript for so long now, new to Flex, showing my ignorance... thanks for the help.

                      T