Robotlegs game with AIR

Astraport's Avatar


14 Sep, 2012 10:05 AM

Hello everybody.

I want to port to AIR (and possibly on mobile devices) existing game created by using Robotlegs framework. The game consists of a menu (one SWF) which link with a few mini games (url to other SWF from the server). Everything works fine. I created AIR app and the game is normally displayed. All the mini-games are in the app folder and everything is OK.

Now I want to in AIR present only in the game menu and other mini-games is downloaded from the server and copied to the user's folder and the main SWF access them. But the problem now - mini-game SWF added to the display list, but they are not visible. That is, if I use the link to the SWF that in app folder, it works. If this link to the user folder, it does not work. There is no error. Naturally, all many times checked, SWF are there.

Any suggest, please. Thank you.

addContextListener(GametEvent.GAME_SELECTED, gameSelectedHandler);

private function gameSelectedHandler(event:SlotEvent):void{
            _currentSlotURL = 'C:/Users/Astraport/AppData/Roaming/com.lll.slotsgametest.debug/Local Store/slots/slotfruit.swf'; //not work
_currentSlotURL = 'slots/slotfruit.swf'; //work
            if (moduleLoader.getModule(_currentSlotURL, ApplicationDomain.currentDomain))
                mainView.addModule(moduleLoader.create(_currentSlotURL) as DisplayObject);
                addContextListener(Event.COMPLETE, completeHandler);
                addContextListener(ProgressEvent.PROGRESS, progressHandler);

private function completeHandler(event:Event):void 
            removeContextListener(Event.COMPLETE, completeHandler);
            removeContextListener(ProgressEvent.PROGRESS, progressHandler);
            mainView.addModule(moduleLoader.create(_currentSlotURL) as DisplayObject);
  1. Support Staff 1 Posted by Ondina D.F. on 14 Sep, 2012 11:32 AM

    Ondina D.F.'s Avatar


    I don’t think that the issue you are encountering has anything to do with robotlegs.
    You can try something like this:

    fileURL ='C:/Users/Astraport/AppData/Roaming/com.lll.slotsgametest.debug/Local Store/slots/slotfruit.swf';
    var file:File;
    file = File.applicationStorageDirectory.resolvePath(fileURL);
    var fileStream:FileStream = new FileStream();, FileMode.READ);
    var bytes: ByteArray = new ByteArray();
    var loaderContext:LoaderContext = new LoaderContext();
    loaderContext.allowLoadBytesCodeExecution = true;
    var swfLoader: SWFLoader = new SWFLoader();
    swfLoader.loaderContext = loaderContext;
    swfLoader.source = bytes;

    You should do a research on security restrictions, SecurityDomain, loading swfs in AIR..

    Here, using cross-domain policy files:


  2. 2 Posted by Stray on 14 Sep, 2012 12:13 PM

    Stray's Avatar

    As Ondina says, for Air, secure loading is a little more complex - basically in order to load a swf such that it has app-sandbox privileges, it needs to be loaded as bytes, not using swfloader.

    Obviously that's dangerous, as Air apps can do a lot of damage in the user's computer if abused. So, generally it's best to sign the swfs to be loaded (packaged as Air) with the same key as the main Air app doing the loading, and check those signatures on loading, rejecting any that fail.

    If this is relevant... let us know - I have a utility that handles secure loading of swfs for air to give them in-app privileges, it's on my github and I have a blog post that explains how to use it.



  3. Support Staff 3 Posted by Ondina D.F. on 14 Sep, 2012 12:36 PM

    Ondina D.F.'s Avatar

    I have a utility that handles secure loading of swfs for air to give them in-app privileges, it's on my github and I have a blog post that explains how to use it.

    I’d like to try this utility, Stray! Link?

  4. 4 Posted by Stray on 14 Sep, 2012 12:41 PM

    Stray's Avatar
  5. Support Staff 5 Posted by Ondina D.F. on 14 Sep, 2012 12:42 PM

    Ondina D.F.'s Avatar

    Many thanks:)

  6. 6 Posted by Astraport on 14 Sep, 2012 01:57 PM

    Astraport's Avatar

    Thanks. I study it.

  7. Support Staff 7 Posted by Ondina D.F. on 14 Sep, 2012 02:19 PM

    Ondina D.F.'s Avatar

    You're welcome.

  8. Ondina D.F. closed this discussion on 14 Sep, 2012 02:19 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