Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: respondTo fails but handleNotification works  (Read 14789 times)
gregbown
Jr. Member
**
Posts: 16


View Profile Email
« on: July 23, 2009, 04:17:19 »

Hello,

I have built Module and Shell Actionscript only projects using PureMVC, Pipes and Fabrication.  I load Module.swf into Shell.swf like so...
req = new URLRequest("Module.swf");
moduleLoader = new Loader();
moduleLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
moduleLoader.load(req);

in completeListener...

var content:FlashApplication = moduleLoader.content as FlashApplication;
content.router = applicationRouter;
content.defaultRouteAddress = applicationAddress;
application.addChild(content);
This seems to be working great, both Module and Shell receive notifications frome each other fine however routing is not working?

in Shell...
routeNotification(CommonConstants.SHELL_TO_MODULE,null,null,"*");//SHELL_TO_MODULE="shellModule"
in Module...
public function respondToShellModule(notification:INotification):void{trace("response recieved");}

I am lost as to how to debug this.  I can inspect the properties of both the module and shell with the Flex debugger but I'm not sure what to look for.  Both router and defaultRouteAddress seem to be getting set. The defaultRoute in the module is set to Shell/Shell0/INPUT.  The applicationAddress is a fabrication.vo.ModuleAddress that is not readable but it is set b in the module so applicationAddress in Shell = (@1b6fda39) and Module defaultRouteAddress = (@1b6fda39). 
The pipes are connected since notifications are sent and received but why are routeNotifications failing?

I have been through the HelloFlash example numerous times and I cant see any differences other than my not using fla files.  There must be something else failing because routeNotification is sending the note fine but only handleNotifications is receiving, respondTo fails?

Any advice is welcome.  Thank you
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #1 on: July 23, 2009, 07:56:05 »

What value does CommonConstants.SHELL_TO_MODULE have? You must ensure your respondTo method uses the same text as CommonConstants.SHELL_TO_MODULE but with an uppercase first letter.

if SHELL_TO_MODULE == ShellToModule
then respondToShellToModule()
Logged
gregbown
Jr. Member
**
Posts: 16


View Profile Email
« Reply #2 on: July 23, 2009, 09:08:00 »

It is documented in first post CommonConstants.SHELL_TO_MODULE="shellModule"
in Module...
public function respondToShellModule(notification:INotification):void{trace("response recieved");}

I have checked and re-checked this and tried using a plain string instead of
static public const SHELL_TO_MODULE:String= "shellModule";
I have tried using the default route instead of specifying "*"
I have tried using a single word like "talk" with respondToTalk???
Thanks anyway.

I am also curious if a module can obtain a route to another module or should I bounce module to module messages off the shell letting the shell act as a switchboard.
Any more ideas?
« Last Edit: July 23, 2009, 09:32:06 by gregbown » Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #3 on: July 24, 2009, 06:18:24 »

Check that you are extending the proper Mediator, FlexMediator.

Try debugging the introspection method to see if something is going wrong there. It is in the FabricationMediator, listNotificationInterests() method. My guess it is something in there that is not properly introspecting since you do get the notifications, they just aren't being transfered to the named methods.
Logged
gregbown
Jr. Member
**
Posts: 16


View Profile Email
« Reply #4 on: July 24, 2009, 02:40:26 »

Thanks for the input Jason,
You say my mediator should extend FlexMediator however I am not using any mx classes it an Actionscript project with flash and fl with no MXML at all.  The Hello Flash mediators extend FlashMediator and my code matches the example.  I am not sure how FlashMediator could work since it is empty compared to FlexMediator.  It does not have any route mapping, class maping or reflection of any kind. FlashMediator extends FabricationMediator wich has these methods inside listNotificationInterests().
I placed a debug marker in FabricationMediator listNotificationInterests() and it never executes.  I wonder if something is missing from the latest release?  I even tried using source zip vs swc no difference.
There must be something I'm missing since Hello Flash uses routeNotification and respondTo ?
A couple of other differences are my file structure My Shell.as and Module.as files exist outside of org, com and fl and I have not implemented a proxy.  Only one of the, I believe four, routeNotifications goes through the proxy though. The final difference is I have a button in the shell to load a module so it is not loaded when ShellMediator onRegister runs.
« Last Edit: July 24, 2009, 08:47:41 by gregbown » Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #5 on: July 24, 2009, 09:18:01 »

Sorry, I meant Flash Mediator. Make sure you don't have an override of listNotificationInterests in your mediator that isn't calling super(). It is wierd that that method isn't getting called and explains why the introspection isn't happening.

I use Fabrication 0.6 with Flash myself and it works perfectly fine.
« Last Edit: July 24, 2009, 09:19:46 by Jason MacDonald » Logged
gregbown
Jr. Member
**
Posts: 16


View Profile Email
« Reply #6 on: July 24, 2009, 09:51:06 »

That was it! I had those functions in both module and shell.  It goes to show sometimes a person needs to look at what is NOT in a working example in comparison to their code.  The exclusion of those functions should be documented for all of us who come from PureMVC Standard, Multicore and Pipes.  I knew it had to be something simple because I could see the routes being set in the debuger.  I really appreciate people like you who take the time to help.  Thank you sooo much!!!

One other question is there a way to connect modules or should I just bounce messages off the shell, rely on the shell to route them?  I have a routeNotification("moduleModule") and respondToModuleModule in both modules that does not work.  I understand a module won't respond to it's own notification.
« Last Edit: July 24, 2009, 10:01:52 by gregbown » Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #7 on: July 25, 2009, 05:58:25 »

No problem, glad you go tit solved.

For Module to Module communications, it should work the same as module to Shell. Just make sure you are either sending it to: '*' or to a specific module name. See http://code.google.com/p/fabrication/wiki/UsingModules for more info on sending to modules.
Logged
Pages: [1]
Print