Please do not double post, if someone can help you they will answer.
The reason you're seeing that behavior is because event listeners are
solely based on the string that your event type evaluates to. So the
following 3 lines are equivalent:
addEventListener(AnswerController.SEARCH_ANSWER_ON_QUESTION, funcOne);
addEventListener(RoamerController.SEARCH_ANSWER_ON_QUESTION, funcTwo);
addEventListener("searchAnswerOnQuestion", funcThree);
As a result, any of the following would trigger all 3 functions:
dispatchEvent(new EventOne(AnswerController.SEARCH_ANSWER_ON_QUESTION));
or
dispatchEvent(new EventTwo(RoamerController.SEARCH_ANSWER_ON_QUESTION));
or
dispatchEvent(new Event("searchAnswerOnQuestion"));
In general I would recommend against having your event types
duplicated but if its unavoidable or you don't want to change it you
can just put an if(event is EventTypeWanted) at the top of the
listener (or Command in this case).
HTH,
Ben
--- In [email protected], "qzhung" <[EMAIL PROTECTED]> wrote:
>
> I built an app used SpringGraph, Yahoo! answer API and Cairngorm,
> display questions and answers (data from Yahoo! answer) like a tree,
> Cairngorm made the code clearly and easily to debug.
>
> Demo and sourceï¼ http://www.moorwind.com/read.php?67
>
> During developing this app I found an interesting Cairngorm error,
> when I creat
> some events super the same type:
>
> //event 1
> public class SearchAnswerOnQuestionEvent extends CairngormEvent
> {
> public function SearchAnswerOnQuestionEvent()
> {
> super(AnswerController.SEARCH_ANSWER_ON_QUESTION);
> }
> }
>
> //event 2
> public class RoamerSOQEvent extends CairngormEvent
> {
> public function RoamerSOQEvent()
> {
> super(RoamerController.SEARCH_ANSWER_ON_QUESTION);
> }
>
> }
>
> If AnswerController.SEARCH_ANSWER_ON_QUESTION and
> RoamerController.SEARCH_ANSWER_ON_QUESTION define the same string such
> as "searchAnswerOnQuestion", than when i dispatched these two events,
> the listerner
> will sonsider them the same event. The following caringorm controls
> will both receive the two events.
>
> //Cairngorm control 1
> public class AnswerController extends FrontController
> {
> public static const SEARCH_ANSWER_ON_QUESTION:String =
> "searchAnswerOnQuestion";
> public function AnswerController()
> {
> this.addCommand(AnswerController.SEARCH_ANSWER_ON_QUESTION,
> SearchAnswerOnQuestionCommand);
> }
> }
> //Cairngorm control2
> public class RoamerController extends FrontController
> {
> public static const SEARCH_ANSWER_ON_QUESTION:String =
> "searchAnswerOnQuestion";
> public function RoamerController()
> {
> this.addCommand(RoamerController.SEARCH_ANSWER_ON_QUESTION,
> RoamerSOQCommand);
> }
> }
>