Need the shared eventDispatcher inside my mxml - specific reason!
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!
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | 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
Support Staff 1 Posted by Shaun Smith on 11 Jan, 2013 08:51 PM
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 Posted by Josh Hartzell on 13 Jan, 2013 08:58 PM
I guess it didn't, I'll post it again :P..
http://blog.somepixels.net/2010/01/how-to-get-bitmapdata-and-bytear...
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.
Support Staff 3 Posted by Shaun Smith on 13 Jan, 2013 09:00 PM
Did you respond to my response? If so, it doesn't look like it came through.
4 Posted by Josh Hartzell on 13 Jan, 2013 10:46 PM
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?
Support Staff 5 Posted by Ondina D.F. on 13 Jan, 2013 11:02 PM
Hi Josh,
your messages have been marked as spam for some reason. I've restored them. Hopefully, everything will be ok from now on.
Ondina
6 Posted by Josh Hartzell on 13 Jan, 2013 11:27 PM
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.
Support Staff 7 Posted by Ondina D.F. on 14 Jan, 2013 11:16 AM
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);
Then:
viewProcessorMap.map(ViewWithoutMediator).toInjection();
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.
Cheers,
Ondina
8 Posted by Josh Hartzell on 14 Jan, 2013 03:11 PM
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!
Support Staff 9 Posted by Shaun Smith on 14 Jan, 2013 10:36 PM
Thanks for the kind words Josh!
If you need any other info on the ViewProcessorMap you can have a read through:
https://github.com/robotlegs/robotlegs-framework/tree/master/src/ro...
Support Staff 10 Posted by Shaun Smith on 14 Jan, 2013 10:39 PM
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 Posted by Josh Hartzell on 15 Jan, 2013 01:25 AM
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
Support Staff 12 Posted by Ondina D.F. on 22 Jan, 2013 10:25 AM
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.
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: http://knowledge.robotlegs.org/discussions/robotlegs-2
See you around :)
Ondina
Ondina D.F. closed this discussion on 22 Jan, 2013 10:25 AM.