Stagecrawler possibly causing stage object to throw null object reference

Kyle's Avatar


27 Jun, 2013 04:39 PM

I have a class called MultiFrameMovieClip which extends MovieClip and adds some basic functionality to make sure that all frames in a (big surprise here) MultiFrame MovieClip have loaded and that any child assets will be available to Actionscript (you can read more about it here: I've been using this class for a while now, and have actually used it without any issue with RL1; however, when I tried using it in my new RL2 project I started receiving null object reference errors.

After a bit of digging around, I found out that it was the stage object that was reporting as null (in the enterFrame event handle of MultiFrameMovieClip). After monitoring the initialization process, I found at that stage is available and set (i.e. not null) up until the point that StageCrawler runs and reports "StageCrawler finished scanning."

I have a number of objects on the timeline of my Flash movie that extend MultiFrameMovieClip; however, none of them (currently) are using a mediator, so my assumption is that the StageCrawler should have no effect on them. From the look of things though, it would seem that the StageCrawler may somehow be nullifying the stage object. Does that seem logical?

I am going to try running the app without loading the StageCrawler extension; however, I may have mediated objects on the timeline going forward, so I may need to load it in the future..

Any thoughts on why this may be occurring or how I might resolve it?



  1. 1 Posted by Kyle on 27 Jun, 2013 04:59 PM

    Kyle's Avatar

    Removing the StageCrawlerExtension had no effect on the stage object being set to null. It now looks like the last thing run before the stage is nullified is MediatorMap.handleView() Before this method, stage is set in my MultiFrameMovieClip class, after this method, stage is null.

  2. Support Staff 2 Posted by Shaun Smith on 27 Jun, 2013 05:09 PM

    Shaun Smith's Avatar

    Hi Kyle,

    There isn't any code in RL that sets the stage property, or removes any view from the stage. If stage is becoming null I'd say that the view component is almost certainly being removed from the stage by somebody. Sorry I can't think of anything else. Let us know what you find.

  3. 3 Posted by Kyle on 27 Jun, 2013 05:12 PM

    Kyle's Avatar

    And yet another tid-bit... If I create the class instances in Actionscript and add them at compile time (as opposed to adding them directly to the timeline), then the code functions correctly and stage remains set. This further points to the fact that something may indeed be happening in the initialization cycle with one of the base extensions.

    My thought at this point is that some extension code is crawling over any objects on the stage (not just those that are being mediated) and somehow nullifying their reference to the stage object.

    Anyone with familiarity of the entire startup sequence, and more specifically how object already on the timeline are handled/effected with some thoughts on this one?

  4. 4 Posted by Kyle on 27 Jun, 2013 05:16 PM

    Kyle's Avatar

    Hey Sean,
    I haven't been able to find any definite culprits while debugging the code either (please don't mistake my grasping at straws for pointing fingers ;-) ). As mentioned in my last comment, this is only happening to objects that exist on the timeline and not to those added via Actionscript such as this:

    contextView.view.addChild(new BuildingPlaceholder()); ==> (this works)

    Would there maybe be something funky happening where objects that are on the timeline exist in a different scope than contextView.view and are somehow attempting to be reassigned and losing their stage reference in the process?

    If I watch the startup sequence for my MultiFrameMovieClip class, when it hits the constructor, stage exists, it then goes through init() and addListeners() methods at which point stage still exists. At around this point, RL starts to bootstrap and runs through loading the extensions, after which the next method in MultiFrameMovieClip is hit and stage is null...

  5. 5 Posted by Kyle on 27 Jun, 2013 05:45 PM

    Kyle's Avatar

    Pointing the finger at myself, pulling RL out of the equation, and testing further.. See how this goes ;-)

  6. 6 Posted by Kyle on 27 Jun, 2013 06:31 PM

    Kyle's Avatar

    Ok. So after further self-introspection (loathing, finger-pointing, etc.), it seems that my very handy MultiFrameMovieClip class may no longer work (currently using Flash CS5.5). This is interesting because it did work quite well with CS5. I think my best approach at this point is to completely ditch the idea of using the timeline to help speed up production and make things pretty, and go back to good old Actionscript programming for addition and management of my child assets that may have existed on frames other than frame 1.

    Blame assigned -> This Guy (well Flash gets some of it!).

  7. Support Staff 7 Posted by Shaun Smith on 27 Jun, 2013 06:56 PM

    Shaun Smith's Avatar

    No worries, I wasn't getting defensive, just pointing out that there isn't any code that I can think of that might do that.

    As a matter of interest, did you try adding a listener for REMOVED_FROM_STAGE inside of your MultiFrameMovieClip, throwing an error in the handler, and inspecting the stack trace?

  8. 8 Posted by Kyle on 27 Jun, 2013 07:05 PM

    Kyle's Avatar

    I hadn't tried that but I will now!

  9. 9 Posted by Kyle on 27 Jun, 2013 07:12 PM

    Kyle's Avatar

    So it IS being removed from the stage. The ADDED_TO_STAGE event fires for the MultiFrameMovieClip, then the REMOVED_FROM_STAGE event fires off. I don't have any code that removes the object, and it is on the timeline and compilation, so this is sort of strange.

    Did you have a thought in regards to what may be pulling it off the display?

  10. Support Staff 10 Posted by Shaun Smith on 27 Jun, 2013 07:30 PM

    Shaun Smith's Avatar

    Does the stack trace not reveal who is doing the removing?

    On 27 Jun 2013, at 20:12, "Kyle" <[email blocked]> wrote:

  11. 11 Posted by Kyle on 27 Jun, 2013 08:45 PM

    Kyle's Avatar

    It shows that the class extending MultiFrameMovieClip is the target of the REMOVED_FROM_STAGE event. The stack trace lists the following as the last item:


    I've done a project-wide search for anything containing remove, and nothing in my source is calling any remove methods. The code executed (as far as I can see) before the REMOVED_FROM_STAGE event is dispatched is this:

    this.gotoAndStop( this.totalFrames );

    If I comment this code out, the REMOVED_FROM_STAGE event is never received and the errors around the stage being null also go away. So it would seem that somehow this is the offending code. So the question now becomes: How the heck does this code nullify the stage, and remove existing MovieClips from the display?

  12. 12 Posted by Kyle on 27 Jun, 2013 09:09 PM

    Kyle's Avatar

    So I created a smaller scope flash pro project using the MultiFrameMovieClip and monitored for the REMOVED_FROM_STAGE event and it does not get dispatched. That being said I have to go under the assumption that there is something happening in my code that I just cannot see. At this point I have to give up the search and move forward, but please let me know if you have any further epiphanies! =]

  13. Kyle closed this discussion on 01 Jul, 2013 10:43 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