Problem: Using viewMap.mapType, to map a Component that is already on stage.

Shawn's Avatar


16 Sep, 2010 08:57 PM

I know I must be missing something here, but I just can't seem to figure this one out.

Here's what I want to do:
1. In my main mxml file, add my context.
2. In the same mxml file, add a self-mediated view
3. In the self-mediated view, I need to inject a singleton instance.
4. I want an init() function in the view to grab some values from the singleton, and use them.

Something like:

<jscompilr:JSCompilrContext contextView="{this}" />

<controls:TopMenu id="topMenu" width="100%" tabChildren="false" />

In my context I use:

In my TopMenu:
[Inject] var strings:StringModel;

However, injection never occurs because the component is already sitting on the stage. When I trace "init()" inside my component, and trace "startup" within my context, init always occurs first.

Now, I know I could manually add the child to the context within startup which would trigger injection. But I'm frustrated I can't figure out how to make this happen automatically using normal MXML layout.

If I used a mediator, I could just override onRegister(), but for a self-mediated view, how do I know that injection has occurred? Or, alternatively, how do I delay instantiation of the view until after startup has occurred ?

  1. Support Staff 1 Posted by Shaun Smith on 16 Sep, 2010 11:14 PM

    Shaun Smith's Avatar

    How are you triggering the init() method in your view component? Have you tried this:

    public function init():void
  2. 2 Posted by Shawn Blais on 17 Sep, 2010 03:30 AM

    Shawn Blais's Avatar

    Wicked that did it :) Thanks for the kick ass framework dude!

    On Thu, Sep 16, 2010 at 5:16 PM, Shaun Smith <
    [email blocked]<tender%[email blocked]>
    > wrote:

  3. Support Staff 3 Posted by Shaun Smith on 17 Sep, 2010 04:02 AM

    Shaun Smith's Avatar

    No probs! I've gotta say: that's a pretty damn slick website you have ( ), nice.

  4. Stray closed this discussion on 16 Feb, 2011 09:07 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