adding child to contextView dispatches Event.ADDED_TO_STAGE twice?

rob's Avatar

rob

14 Jan, 2011 01:24 AM

Sorry if this has already been posted before. I searched the forums a bit but couldn't find any mention of it.

I have a Shell swf which loads my Main swf. As soon as Main is added to stage I set it as the context view and fire my startup command.

In my startup command I say:

        var applicationView:ApplicationView = new ApplicationView();
        contextView.addChild(applicationView);

I noticed that when I have a listener in my view for Event.ADDED_TO_STAGE it ends up firing twice. However, if I add it directly to contextView's stage property it only fires once (which seems like the correct behavior to me):

        var applicationView:ApplicationView = new ApplicationView();
        contextView.stage.addChild(applicationView);

Does that sound right..?

  1. Support Staff 1 Posted by Till Schneidere... on 14 Jan, 2011 10:45 AM

    Till Schneidereit's Avatar

    Hi Rob,

    that really shouldn't happen. What exactly are the symptoms you're
    seeing that lead to that conclusion? Note that Robotlegs listens to
    the ADDED_TO_STAGE event in the capture-phase, not in the
    targeting-phase like most "normal" listeners would. So if, in your
    application, you have an additional listener to that event, it would
    get the event after Robotlegs, but shouldn't get it twice.

    If that doesn't explain anything at all - as it probably won't - can
    you maybe give some example code that replicates what you're seeing?

  2. 2 Posted by rob on 09 Feb, 2011 05:13 PM

    rob's Avatar

    I'm sorry for not replying sooner, I'm in the middle of a project so I haven't been able to take apart my code. I believe I'm screwing up my contextView mediation and that's causing the issue. I'll post a very simple example after the 14th :]

  3. Support Staff 3 Posted by Till Schneidere... on 09 Feb, 2011 05:26 PM

    Till Schneidereit's Avatar

    No worries, you'll get to it when you get to it. But for now: Good
    luck with the project!

  4. Stray closed this discussion on 02 May, 2011 01:26 PM.

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

Keyboard shortcuts

Generic

? 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