Need the shared eventDispatcher inside my mxml - specific reason!

Josh Hartzell's Avatar

Josh Hartzell

10 Jan, 2013 12:41 AM

I have an embedded mp3 file that I am including in my app for connection testing purposes, it will send a file to the server validate md5's and respond back..

The only way I can get the bytearray of the embedded mp3 is doing it inside the MXML. I know this sounds crazy however I've researched tons and tried many different things.. Feel free to test yourself :)

I'm trying to dispatch events inside of this MXML instead of using a mediator as I generally do. But I can't seem to figure out how to get my shared event dispatcher into the MXML.. I have tried a few different things that failed..

Thanks in advance!

  1. Support Staff 1 Posted by Shaun Smith on 11 Jan, 2013 08:51 PM

    Shaun Smith's Avatar

    Hello Josh,

    That does sound crazy! Got any links, or example code, that shows it working in MXML but not plain AS3? Anyhoo..

    Can't you just pass the event dispatcher through to the component from the Mediator? If you don't want to do that you could inject the IEventDispatcher directly into the component by using the ViewMap (RL1) or the ViewProcessorMap Extension (RL2).

    Hope that helps!

  2. 2 Posted by Josh Hartzell on 13 Jan, 2013 08:58 PM

    Josh Hartzell's Avatar

    I guess it didn't, I'll post it again :P..

    Give that link a try in a new flex project, try it inside the MXML first to see it working correctly, then try it inside AS3. I didn't actually try this exact example because I am embedding an mp3 so it's a bit different however my above statement holds true.

    Also would it be possible for you to give a small example of the ViewProcessorMap extension? I've never used it and am using RL2.

  3. Support Staff 3 Posted by Shaun Smith on 13 Jan, 2013 09:00 PM

    Shaun Smith's Avatar

    Did you respond to my response? If so, it doesn't look like it came through.

  4. 4 Posted by Josh Hartzell on 13 Jan, 2013 10:46 PM

    Josh Hartzell's Avatar

    I tried posting a response like 20 minutes after your response and said it had to be processed but it never showed up..

    I have a link but I think that is what is blocking my post from posting.. this is the post without the link.

    That is an example of an embedded img file and using BitMapData, I havent actually tried it with a img but you can reproduce this functionality with an MP3 and then try to get the bytearray from the embedded mp3, I was unable to do it unless it was inside the MXML..

    Anywho, could you possibly show a few examples of your solution and also maybe show an example of how the ViewProcessorMap is used? I'm a little confused, how would I pass the eventDispatcher from my mediator to the view?

  5. Support Staff 5 Posted by Ondina D.F. on 13 Jan, 2013 11:02 PM

    Ondina D.F.'s Avatar

    Hi Josh,

    your messages have been marked as spam for some reason. I've restored them. Hopefully, everything will be ok from now on.


  6. 6 Posted by Josh Hartzell on 13 Jan, 2013 11:27 PM

    Josh Hartzell's Avatar

    I'm sorry about that! :P You can delete a few of the duplicates if you like just delete the ones that are more convoluted, keep the one you understand :P I was just trying different alterations to see if something I was doing in the form was illegal or failing moderation validation haha.

  7. Support Staff 7 Posted by Ondina D.F. on 14 Jan, 2013 11:16 AM

    Ondina D.F.'s Avatar

    Hey Josh,

    Don’t be sorry! We are sorry for the inconvenience :) Your last message has been marked as spam again. The moderation you were talking about is not coming from our staff, but from Tender Support (the app hosting our forum).
    If it's not too much trouble, would you mind creating an account? You’re listed as an anonymous user. Hopefully, as a registered user your posts won’t be marked as spam again.

    Regarding your question about the ViewProcessorMapExtension, I’ve never used it until now, but I’ll give it a try:

    In your context config class:

    context.install( ViewProcessorMapExtension );

    Depending on how your config class looks like, you either do this:

    [Inject] public var viewProcessorMap:IViewProcessorMap;

    or this:

    private var viewProcessorMap:IViewProcessorMap;
    viewProcessorMap = injector.getInstance(IViewProcessorMap);


    In your ViewWithoutMediator:

    [Inject] public var sharedDispatcher:IEventDispatcher;

    Somewhere in the view:

    sharedDispatcher.dispatchEvent(new SomeEvent(SomeEvent.SOME_TYPE, "some message"));

    Then you add a listener for that event on the shared dispatcher within the classes that need to react to that event.

    If I’m wrong about the usage of viewProcessorMap, Shaun will surely provide more info or examples.


  8. 8 Posted by Josh Hartzell on 14 Jan, 2013 03:11 PM

    Josh Hartzell's Avatar

    Not a problem at all fellas, I appreciate the help tremendously. I have fallen in love with RobotLegs and its' simplicity. It has taken AS3 and Flex from being a language I despise to a language I actually enjoy working with. Thanks for such a great framework!

    As for the technical details; thanks so much again! This looks great I will give it a shot!

  9. Support Staff 9 Posted by Shaun Smith on 14 Jan, 2013 10:36 PM

    Shaun Smith's Avatar

    Thanks for the kind words Josh!

    If you need any other info on the ViewProcessorMap you can have a read through:

  10. Support Staff 10 Posted by Shaun Smith on 14 Jan, 2013 10:39 PM

    Shaun Smith's Avatar

    Btw, what IDE are you using? If you're using FB4.7 then it's possible that you'd be compiling plain as3 projects with ASC2. ASC2 might have a bug related to Embedding. When switching to MXML you'd then be switching to the legacy compiler (mxmlc) which does not have such a bug. Just thinking aloud.

  11. 11 Posted by Josh Hartzell on 15 Jan, 2013 01:25 AM

    Josh Hartzell's Avatar

    I've just recently switched over to IntelliJ and I'm in love ;) -- I did think of that possibility but it wasn't the issue in 4.6

  12. Support Staff 12 Posted by Ondina D.F. on 22 Jan, 2013 10:25 AM

    Ondina D.F.'s Avatar

    Josh, I'm assuming this is resolved. I’m going to close this discussion for now, but you can re-open it if need be.

    I have fallen in love with RobotLegs and its' simplicity.

    Me too, a long time ago! And the feelings are still lasting ;-)

    If you have other questions about rl2, please don’t hesitate to open new discussions, preferable under this category:

    See you around :)


  13. Ondina D.F. closed this discussion on 22 Jan, 2013 10:25 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