Context startup() method suddenly stopped firing - HELP!

Kyle's Avatar


22 Sep, 2011 06:47 PM

Hey guys,
I've been chugging along on my project, everything building fine, just going through the debug process. When I left the project last night, everything was building properly. This morning, I go to build my project, and for some reason the startup() method in my context no longer gets called. I've tried cleaning my project, rebooting my machine, and just about every other random idea I could come up with, but it still is not firing. I can't find anything in my code that would be causing this, my context declaration inside of my main application still appears to be correct, and is passing in contextView="{this}" as it always has. I know that the context is being created because the constructor does get called.

Any thoughts on what might be causing this???



  1. 1 Posted by Kyle on 22 Sep, 2011 06:56 PM

    Kyle's Avatar

    More Info:
    I am using Flashbuilder 4.5 on Mac OSX Lion. I have tried running as both a debug build and a normal build, and just in case it was a metadata stripping issue, I have tried adding the following compiler options:

    -keep-as3-metadata+=Inject -keep-as3-metadata+=PostConstruct

  2. 2 Posted by digitaldavenyc on 22 Sep, 2011 07:11 PM

    digitaldavenyc's Avatar

    How are you instantiating your robotlegs context?

    You may need to set autoStartup to true or dispatch the context startup event

    dispatchEvent( new ContextEvent(ContextEvent.STARTUP) );

    • Dave
  3. 3 Posted by Kyle on 22 Sep, 2011 07:12 PM

    Kyle's Avatar

    More More Info:
    Digging through and adding a few breakpoints, it appears that the onAddedToStage() method never gets called. It looks like this is what actually calls the startup() method, so perhaps the question is: Why is the onAddedToStage() method not getting called? Any ideas on that?

  4. 4 Posted by Kyle on 22 Sep, 2011 07:14 PM

    Kyle's Avatar

    Hey Dave,
    I have a Flex project, and I'm instantiating my context in my main application file in the declarations tag (this has been working just fine for the last few weeks).

        <!-- Context File -->
        <videoplayer:VideoPlayerContext contextView="{this}" />

    It doesn't appear that you can access the autostartup via MXML (not exposed via a setter).

  5. 5 Posted by Kyle on 22 Sep, 2011 07:20 PM

    Kyle's Avatar

    When checkAutoStartup() gets called in the context, it executes the following code:

     contextView.stage ? startup() : contextView.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);

    The result of this is that the listener gets added since at the time this method fires, contextView.stage is reporting null. Again, not sure why this would suddenly start happening, as it has been working fine for the last few weeks, and I can't think of any coding change that i could make that would effect this...

  6. 6 Posted by digitaldavenyc on 22 Sep, 2011 07:28 PM

    digitaldavenyc's Avatar

    You can set it in your VideoPlayerContext class

    public class VideoPlayerContext extends Context
        public function VideoPlayerContext(contextView:DisplayObjectContainer, autoStartup:Boolean = true)
            super(contextView, autoStartup);
  7. 7 Posted by Kyle on 22 Sep, 2011 07:40 PM

    Kyle's Avatar

    Right on!

    At this point it's starting to look like one of my view components might be causing the issue. I've gone line by line removing various uicomponents/views from my application file, and I think I've found the culprit. It's an extremely strange behavior, basically, a single component is somehow (silently, i.e. no problems reported, no errors thrown) causing the Applications applicationComplete, and creationComplete events not to fire, which is what I assume is breaking the context and not allowing it to fire its' startup method. I will report back when I figure this thing out!



  8. 8 Posted by Kyle on 22 Sep, 2011 07:45 PM

    Kyle's Avatar

    I found the culprit. The following 3 lines of code managed to single-handedly (and silently) bring down the entire application and prevent the applicationComplete events from firing in the main Application file:

                <s:SolidColorStroke color="{getStyle('accentColor')}" alpha="{getStyle('accentAlpha')}" />

    I don't think there's enough room in the DB to store the amount of gripes (see also issues, see also complaints) about Flashbuilder 4.5 and it's insane bugginess, but needless to say I'll be adding this to the long, long list...

    Thanks for the help Dave!

  9. 9 Posted by digitaldavenyc on 22 Sep, 2011 07:52 PM

    digitaldavenyc's Avatar

    That sounds like it could be part of your problem, robotlegs should be living at the top level of your application not just a view component from within it. You can use it in the way that you are but it's not considered a good practice and you run into problems more frequently like the one you just had. I agree anything in eclipse is mediocre at best. Glad to help and good luck.


  10. 10 Posted by Kyle on 22 Sep, 2011 07:58 PM

    Kyle's Avatar

    Hey Dave,
    Robotlegs (i.e. my context) DOES live at the top level of my application. It is declared in the tag of my main application file. The view component I was referring to was a child element of my main application, and was a separate component (having nothing to do with my context).

  11. 11 Posted by digitaldavenyc on 22 Sep, 2011 08:09 PM

    digitaldavenyc's Avatar

    Gotcha seemed like you were nesting inside your app, my fault.

  12. Kyle closed this discussion on 02 Oct, 2011 09:54 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac