Passing Data from RobotLegs to Non-RobotLegs

digitaldavenyc's Avatar


13 Sep, 2010 10:11 PM

I am working on a pure as3 robotlegs application that will act as a "shell" and process all data and load external swf files, the swf files are non-robotlegs. My shell needs to load the swfs and send them the data when they are ready to receive it. I'm trying to set it up where the robotlegs app and the external swfs dispatch events that communicate with each other but unfortunately its not working.

When my assets are loaded into the external swf file it dispatches an event that is being bubbled but the robotlegs shell doesn't recognize that this event has been fired. The event is mapped into a mediator:


override public function onRegister():void
    eventMap.mapListener(eventDispatcher, ShellEvent.SWF_READY, onSWFReady);

` I also need to send data into these external swfs when I know they are ready for it. Can someone shed some light on why this isn't working or a better method for communicating between external swfs via robotlegs.

  1. Support Staff 1 Posted by Shaun Smith on 13 Sep, 2010 10:29 PM

    Shaun Smith's Avatar


    The problem is that you are listening to your context's event dispatcher (which is not on the display list) - to catch those bubbling events you should be listening to a node on the display list (probably the view component in your mediator).

    To talk to your loaded SWFs you would define lightweight interfaces (apis) and talk through those. The interfaces would also be compiled into the shell, but that's OK as they will be tiny. For example:

    public interface IRunnable
        function run():void;

    An external SWF might implement such an interface, and the shell would reference it as such. For example:;

    Hope that helps!

  2. 2 Posted by digitaldavenyc on 14 Sep, 2010 03:28 PM

    digitaldavenyc's Avatar

    Yes that does help. Seems like you need public functions in the main class of the external SWFs in order to pass data directly into them.

    I have another issue with passing data from the robotlegs shell into a child robotlegs swf. How would you go about passing data this way?

  3. 3 Posted by Stray on 14 Sep, 2010 03:36 PM

    Stray's Avatar

    For child RL swfs, use robotlegs modular.

    Joel Hooks has the most up to date code base on his github fork.

  4. 4 Posted by digitaldavenyc on 14 Sep, 2010 08:49 PM

    digitaldavenyc's Avatar

    Thanks stray that should work out great. I have another question though... If you have a standard robotlegs application how do you pass data into it from a parent swf? Is there a way to inject into the context when u initialize the framework?

  5. 5 Posted by Stray on 15 Sep, 2010 10:10 AM

    Stray's Avatar

    The context doesn't have to run startUp automatically - there's a parameter you can pass in to your context when you create it to set that to false. Or you can hold off creating your context until you have the data you need in the loaded swf.

    Assuming that the parent swf is non-RL, I'd use conventional methods to pass the data between the two, probably put the required variables into a strongly typed parameters object once they arrive, and then create my context once that has happened - using autostartup=false and only starting up when I've passed the parameter object into the context.

    The nuts and bolts of how you actually do it will depend on the security restrictions imposed by the application's environment, and the application domain you're loading your swf into.

    For example - in Air you can only pass vanilla objects and plain data (String, Number etc) to swfs which are in the non-Application domain, and you'd need to expose a sandbox bridge on the child swf or parent swf to push/pull the data as individual values.

    I'm not aware of a way to inject automagically into the context in this scenario (especially given the varying requirements of different security and application domains) - anyone else?

  6. 6 Posted by digitaldavenyc on 17 Sep, 2010 09:58 PM

    digitaldavenyc's Avatar

    thanks a lot stray, that was a great help. I got my app running now.

  7. Stray closed this discussion on 12 Feb, 2011 11:03 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