how injec Stage to the Service?

nexus6's Avatar


12 Apr, 2012 12:29 AM

I have a loader service class with console window displays loading informations. What I need is add this console window directly to the stage. How to do that?

I need somthing like this:

public class Service extends Actor{

[Inject] public stage:Stage;   
var console:Console = new Console();


  1. 1 Posted by Abel de Beer on 12 Apr, 2012 09:02 AM

    Abel de Beer's Avatar

    Hi nexus6, (Blade Runner reference, yay!)

    First I'd like to point out that you're attempting something that goes against the separation of responsibilities that is described in the MVCS pattern. Models and Services shouldn't care about the representation of their data and merely send Events (or Signals) to the rest of the application so that the View tier can respond to it.

    What I'd suggest is you take this route:
    - your Service dispatches the required loading Events (open, progress, complete...) - you create a Mediator for you Console View that listens to these events - the Mediator calls the appropriate methods on your Console component to displat the information

    If you still think your approach is the right one, you'd do this in your Service:

    [Inject] public var contextView:DisplayObjectContainer;

    contextview.stage.addChild(new Console());

    For more info on Robotlegs' implementation of the MVCS pattern (recommended!):
    * Flow diagram: * Best practices:

  2. 2 Posted by nexus6 on 12 Apr, 2012 11:31 AM

    nexus6's Avatar

    Hi Abel de Beer ( I love beer and Blade Runnder too :) )

    Great, it works like I want to!

    I know it's against the MVCS pattern, but i this case I don't want mess my application model and view with this service console (simple text window). I use this just for debugging purposes. It's not part of app so i want directly add it to the stage from the service.

    Thank You!

  3. Ondina D.F. closed this discussion on 19 Apr, 2012 08:55 AM.

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