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: notifications problem  (Read 8617 times)
Tack
Newbie
*
Posts: 3


View Profile Email
« on: July 15, 2009, 01:06:31 »

Hello,

I've recently stumbled upon a very weird problem regarding the notifications. I'll explain exactly how it goes.

In my main application i have a couple of components, like this:

<view:Component1 ... />
<view:Component2 ... />
<view:Component3 ... />

//the namespace xmlns:view="com.view.components.*" is included the <Application> tag

Each of these components have their own mediators registered in the StartupCommand.

All good so far, if i run the application like this (without any notifications), all mediators are responding perfectly.

HOWEVER, when i add notifications to the mediators, only the first component is receiving and executing them, none of the other component do (whether it's the same notification or different ones). If i delete the first component, then the 2nd one is receiving the notifications (but not the rest) and so on.

The mediators all have different assigned names.. can someone enlighten me on this? I'm really clueless about how to fix it.

Thanks in advance.

Tack
Logged
serka
Newbie
*
Posts: 9


View Profile Email
« Reply #1 on: July 15, 2009, 04:20:41 »

You'll have to provide more details. Perhaps some code?

if i run the application like this (without any notifications), all mediators are responding perfectly.
What do you mean they are responding perfectly? What are they responding to if there aren't notifications?
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: July 15, 2009, 11:26:21 »

Sounds as if you may have registered three instances of the same mediator without giving them unique names. Remember that the NAME constant is only a convenient practice when you have only one instance of a mediator to register.

-=Cliff>
Logged
Tack
Newbie
*
Posts: 3


View Profile Email
« Reply #3 on: July 17, 2009, 12:15:04 »

Thanks for the replies. This is what my code looks like, it's 3 different mediators, i don't know why it's not working :|
If anyone can figure it out, i'll be very grateful!

StartupCommand.as:
facade.registerMediator(new ApplicationMediator(app));
facade.registerMediator(new LocalVideoOutputMediator(app.localVideoDisplay));
facade.registerMediator(new OnlineVideoOutputMediator(app.onlineVideoDisplay));
facade.registerMediator(new ChatMediator(app.chat));

mainApp.mxml
<mx:Application layout="absolute" xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:view="com.view.components.*" applicationComplete="facade.startup(this);" width="680" height="440">

<view:LocalVideoOutput id="localVideoDisplay" x="340" />
<view:OnlineVideoOutput id="onlineVideoDisplay" x="0" />
<view:chat id="chat" x="0" y="240" />


OnlineVideoOutputMediator.as:
:
package com.view
{
import com.ApplicationFacade;
import com.view.components.OnlineVideoOutput;

import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

public class OnlineVideoOutputMediator extends Mediator implements IMediator
{
public static const NAME:String = 'OnlineVideoOutputMediator';

public function OnlineVideoOutputMediator(viewComponent:Object=null)
{
super(mediatorName, viewComponent);
}

override public function listNotificationInterests():Array
{
return [ApplicationFacade.STREAM_IN
];
}

override public function handleNotification(notification:INotification):void
{
switch(notification.getName())
{
case ApplicationFacade.STREAM_IN:
trace("init online webcam..");
this.onlineVideoOutput.initOnlineCam();
break;
}
}

private function get onlineVideoOutput():OnlineVideoOutput
{
        return viewComponent as OnlineVideoOutput;
}

}
}

LocalVideoOutputMediator.as:
:
package com.view
{
import com.ApplicationFacade;
import com.view.components.LocalVideoOutput;

import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

public class LocalVideoOutputMediator extends Mediator implements IMediator
{
public static const NAME:String = 'LocalVideoOutputMediator';

public function LocalVideoOutputMediator(viewComponent:Object=null)
{
super(mediatorName, viewComponent);
}

override public function listNotificationInterests():Array
{
return [ApplicationFacade.STREAM_OUT];
}

override public function handleNotification(notification:INotification):void
{
switch(notification.getName())
{
case ApplicationFacade.STREAM_OUT:
trace("init local webcam..");
this.localVideoOutput.initLocalCam();
break;
}
}

private function get localVideoOutput():LocalVideoOutput
{
        return viewComponent as LocalVideoOutput;
}

}
}

ChatMediator.as:
:
package com.view
{
import com.ApplicationFacade;

import org.puremvc.as3.interfaces.IMediator;
import org.puremvc.as3.interfaces.INotification;
import org.puremvc.as3.patterns.mediator.Mediator;

public class ChatMediator extends Mediator implements IMediator
{
public static const NAME:String = 'ChatMediator';

public function ChatMediator(viewComponent:Object=null)
{
super(mediatorName, viewComponent);
}

override public function listNotificationInterests():Array
{
return [ApplicationFacade.STREAM_IN];
}

override public function handleNotification(notification:INotification):void
{
switch(notification.getName())
{
case ApplicationFacade.STREAM_IN:
trace("chat stream in");
break;
}
}

}
}
Logged
Jason MacDonald
Sr. Member
****
Posts: 243


View Profile Email
« Reply #4 on: July 17, 2009, 06:19:05 »

Your super call in all 3 mediators is passing "mediatorName" instead of the "NAME" constant. Try changing that and it should work.
Logged
Tack
Newbie
*
Posts: 3


View Profile Email
« Reply #5 on: July 17, 2009, 07:30:50 »

Your super call in all 3 mediators is passing "mediatorName" instead of the "NAME" constant. Try changing that and it should work.

THAT WAS IT! thank you so very much!!!  ;D
Logged
Pages: [1]
Print