Announcement Announcement Module
Collapse
No announcement yet.
applicationContext.load never calls the EventComplete handler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • applicationContext.load never calls the EventComplete handler

    My Spruing initialization is as follows

    contextURL="application_context.xml";

    applicationContext.addConfigLocation(contextURL);
    applicationContext.addEventListener(Event.COMPLETE , handleComplete);
    applicationContext.load();


    private function handleComplete():void{
    logger.send("handleComplete called");
    var mainAnimation:MainAnimation = applicationContext.getObject.("mainanimation") as MainAnimation;
    logger.send("Starting Main application");
    mainAnimation.start();
    }


    handleComplete is never called.

    There are a number of possible problems.
    1) Is there any way to provide a handler to catch "file not found". A pretty common type of problem specially in an IDE like FDT where so much is automated.
    2) Where does the application_context.xml file go in FDT to get it in the right place when Run As is selected
    3) Can I find out if the application_context is read but perhaps does not parse.

    Anything else that I should try to get this working?

  • #2
    should throw errors

    Hey Ron,

    I have no experience with FDT, so the right set up with this I couldn't help you with. But the fact that the context doesn't load AND doesn't throw errors seems a bit weird to me.
    Spring Actionscript throws errors in cases of file not found or parsing errors, so the fact that your code code doesn't do anything at all, to me, seems to indicate a problem of an entirely different nature.
    Normally the context (xml) file just needs to be copied into the same directory where your binary is placed, that way it'll be picked up at runtime without problems.

    cheers,

    Roland

    Comment


    • #3
      Thanks for the reply. That is somehat reassuring.

      Perhaps I am not a typical new user since I have a lot of experience using Spring with STS and Java and have not used Actionscript for a while (AS2).

      I gather that the target for the documentation is FlexBuilder.
      I would like to see a bit of attention paid to FDT with STS (or Eclipse where there is a difference).

      At a minimum, I would like to see a section describing what is the recommended way to set up a "typical" Spring ActionScript project.
      I would expect it to be very short.
      For STS/FDT:
      1) How to set the libraries - see my other post for details that I would like added to the download page.
      2) How to structure the top levels of the project so that the build works and the context files are found.
      3) How to log and debug a Sprint Actionscript project.

      Perhaps there could be references to the FDT documentation for some of the details.


      For FlexBuilder, I can only guess that it is similar.


      I tried to force an error by adding extraneous characters to the file name but it did not put anything in my logs
      It did draw a sphere and a box on my Flash view so I know it got past the applicationContext.load

      Any suggestions about how to do a better job of debugging this.
      If you can see what I did wrong, that would also be a help.


      This is the code:

      logger=new MockDebugLogger();
      logger.start();

      // Start of real life
      contextURL="application_context.xxxxml";
      logger.send("Loading Spring context with ContextURL set to "+contextURL);
      /*
      *If the contextURL is read from the html that starts the application, then you need to add a place to load it and initialize it.
      *
      * addEventListener(Event.PREINITIALIZE,handlePreInit );
      */
      applicationContext=new XMLApplicationContext();
      applicationContext.addConfigLocation(contextURL);
      logger.send("Added Spring context with ContextURL set to "+contextURL);
      applicationContext.addEventListener(Event.COMPLETE , handleComplete);
      applicationContext.addEventListener(IOErrorEvent.I O_ERROR, IOErrorHandler);

      applicationContext.addEventListener(Event.ADDED, listenerAdded);
      logger.send("Added Listeners for applicationContext.load");
      applicationContext.load();
      logger.send("Initiated Load of Spring context with ContextURL set to "+contextURL);
      scene.root.addChild(new Box( "myBox" ) );
      scene.render();
      private function handleComplete():void{
      logger.send("handleComplete called");
      var mainAnimation:MainAnimation = applicationContext.getObject.("mainanimation") as MainAnimation;
      logger.send("Starting Main application");
      mainAnimation.start();
      }
      private function IOErrorHandler():void{
      logger.send("ApplicationContext Listener IO Error");

      This is the log output

      [10:46.34 SYSTEM] POWERFLASHER SOS max (Build 1004)
      [10:46.52 ] Loading Spring context with ContextURL set to application_context.xxxxml
      [10:46.52 ] Added Spring context with ContextURL set to application_context.xxxxml
      [10:46.52 ] Added Listeners for applicationContext.load
      [10:46.52 ] Initiated Load of Spring context with ContextURL set to application_context.xxxxml
      [10:46.52 ] Connection to logging socket successfully made!


      Note that the bad filename is in the last message received but did not trigger a call to IOErrorHandler().
      [10:46.52 ] Connection to logging socket successfully made!
      seems to be out of sequence in the log. I am not sure why.

      Comment


      • #4
        Hi Ron,

        we use the AS3Commons-Logging library for internal logging in the framework. By default all logging is redirected to the output console using trace(). Can you check what the output of the console is and post it here?

        If have used FDT in the past but have no current experience with it. In my current IDE, I use an Ant target to copy all externally loaded files to the output folder before it compiles and runs the application.

        regards,
        Christophe

        PS: if you are using the Flex framework, you can configure its Log to include the SOSTarget we provide and then set up a flex logger in AS3Commons Logging.

        Comment


        • #5
          C:/Users/rwheeler/DOCUME~1/WORKSP~1.REL/VISION~2/MAINPR~1.SWF (96075 bytes)
          (fcsh)
          ----------
          Launch External SWF Viewer



          That is all I get in the console. I added a
          trace("Starting MainProgram");
          to the start of the Main Program.
          It does not go in the STS console window but the flash window draws the sphere and box and the SOS log shows
          [12:53.21 ] Loading Spring context with ContextURL set to c:/application_context.xml
          [12:53.21 ] Added Spring context with ContextURL set to c:/application_context.xml
          [12:53.21 ] Added Listeners for applicationContext.load
          [12:53.21 ] Initiated Load of Spring context with ContextURL set to c:/application_context.xml
          [12:53.21 ] Connection to logging socket successfully made!

          I put the application_context.xml in the root of the C drive to make it's location explicit.

          Is there anything that I can ask the applicationContext just see if it is instantiated correctly?

          Comment

          Working...
          X