Loading the assets

amkoky's Avatar


09 Oct, 2013 05:29 PM

I'm new using RL and I started a new project trying to use it. My first problem is that I'm coding a pure AS3 project. So, I need to load all my assets. I thought in creating a service, but I don't know when and how call the service. I thought that steps:
- when the app is initialized, I create the context.
- the next step is to create the main view (injecting the eventDispatcher)
- when the main view is added to stage, I dispatch the event "MyEvent.LOAD_ASSETS"
- in the appConfig file i have,
 "commandMap.map(MyEvent.LOAD_ASSETS, MyEvent).toCommand(LoadAssetsCommand);"

- and finally, the LoadAssetsCommand calls the service and loads my assets.

But I have a problem when I run the app. I dispatch the event ("MyEvent.LOAD_ASSETS"), but nothing happens :-(

Somebody has an idea? are there a better way to do that?

Thanks for your time in advance.

  1. 1 Posted by amkoky on 09 Oct, 2013 06:07 PM

    amkoky's Avatar

    Sorry, I had a mistake. I can't dispatch the event. When I try to do it, I obtain an error because the eventDispatcher is null.

  2. 2 Posted by amkoky on 10 Oct, 2013 08:56 AM

    amkoky's Avatar

    Hi again!

    Ok, I change a bit the steps:
    - when the app is initialized, I create the context.
    - I create a view and dispatch MyEvent.LOAD_ASSETS when the view is added to stage.(without inject anything)
    - In the viewMediator I add "addViewListener(MyEvent.LOAD_ASSETS, dispatch, MyEvent);"

    - in the appConfig file I have,
     "commandMap.map(MyEvent.LOAD_ASSETS, MyEvent).toCommand(LoadAssetsCommand);" and "mediatorMap.map(MainView).toMediator(MainViewMediator); "

    Now I don't have an error, but nothing happens. The execute function in the LoadAssetsCommand is not called

  3. 3 Posted by amkoky on 10 Oct, 2013 10:12 AM

    amkoky's Avatar

    And here is the test project. I don't know what else I can do :-(

  4. Support Staff 4 Posted by Shaun Smith on 10 Oct, 2013 10:31 AM

    Shaun Smith's Avatar

    Hello Carlos,

    I haven't looked properly, but noticed that you didn't override the clone() method in your custom event. See: https://github.com/robotlegs/robotlegs-framework/wiki/common-proble...

    Hopefully that will fix it.

  5. 5 Posted by amkoky on 10 Oct, 2013 10:35 AM

    amkoky's Avatar

    OMG! BINGOO!!!!!!! Thanks Shaun. Just that was the problem.

  6. Support Staff 6 Posted by Shaun Smith on 10 Oct, 2013 10:46 AM

    Shaun Smith's Avatar

    Cool! Without overriding clone the event will be turned into an object of type Event instead of MyEvent when redispatched (or bubbled). Because your mapping explicitly requires an event of type MyEvent the plain event will be ignored.

  7. amkoky closed this discussion on 14 Oct, 2013 08:35 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