Robotlegs and the use of FileReference

Bert Deterd's Avatar

Bert Deterd

12 Jun, 2011 08:02 PM

Hello All,

I'm working with as3xls and created an Excel File. This all works nice. Now the last step is to save the file local. (FileReference, method SAVE).

However FileReference can only be used with user events. How can I use FileReference in conjuction with Robotlegs. If I put all my logic in a command Flash does not see that it is a user command any longer.

  1. 1 Posted by Stray on 12 Jun, 2011 08:11 PM

    Stray's Avatar

    Hi Bert, you'll need to use a Service - which is long lived and should be mapped as a singleton / singletonOf, and just call the service from a command.

    Services just extend Actor.

    The other option is to use


    to stop the command dying and then


    when you have finished the user action.

    I usually use a service for this though - it feels a little too heavy for a Command to me.

    Let me know if you need more help with this.


  2. 2 Posted by Bert Deterd on 12 Jun, 2011 09:33 PM

    Bert Deterd's Avatar

    Thank you for your reply.

    Tried to implement the service, but I get the same error when I call the service from a Command. There should be a user-action like a MouseEvent (click) of some sort for to work.

    Any help will be appreciated.


  3. 3 Posted by Stray on 12 Jun, 2011 09:40 PM

    Stray's Avatar

    Hi Bert, sorry, I'm not able to understand what your problem is - are you not getting the File selection event back from the dialog when the user chooses it?


  4. Support Staff 4 Posted by creynders on 13 Jun, 2011 07:13 AM

    creynders's Avatar

    @stray: no Bert means the restriction that you can't save a file unless if it's directly invoked by user interaction.

    @bert: there's no other option than using a filerefence instance directly. I'd create a service which uses/wraps filereference and publicly exposes its instance. Then let the mediator pick it up and pass to the view.
    The thing is I remember having it called further down the road, but I haven't been able to figure out where the treshold is, so I couldn't advise you where else to call it than in the mouse event handler.
    I seem to remember I succeeded in having the FR instance encapsulated in a service and yet be able to save the file, but since you tested that out, probably I'm mistaken.
    Did you instantiate the FR instance in the service BEFORE the mouse click or AFTER? I seem to remember it made a difference.

  5. Support Staff 5 Posted by creynders on 13 Jun, 2011 03:17 PM

    creynders's Avatar

    Hmm I spiked the view > viewevent > mediator > frameworkevent > command > service flow and it doesn't throw an error. If you want I can put up the source on github.
    This is the really nasty thing about it. It works until too much stuff gets in between and then suddenly it throws the error.

  6. 6 Posted by Bert Deterd on 14 Jun, 2011 12:13 PM

    Bert Deterd's Avatar

    Hi creynders,

    If you can provide the source that would be very nice.
    I worked around my issue for now and did the within the view .
    Would be very nice if there is a stable solution to get it to work in a command / service.


  7. Support Staff 7 Posted by creynders on 14 Jun, 2011 12:47 PM

    creynders's Avatar
  8. Support Staff 8 Posted by Ondina D.F. on 02 Nov, 2011 03:41 PM

    Ondina D.F.'s Avatar

    Hi Bert,
    If you want to continue this discussion, feel free to reopen it. I’m closing the thread now.
    Please open new threads for new issues.
    Thank you for posting.

  9. Ondina D.F. closed this discussion on 02 Nov, 2011 03:41 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