List Info

Thread: ChannelBroadcaster example




ChannelBroadcaster example
user name
2006-12-08 15:15:48
Hello Cédric !
 
Is there a way to broadcast an event to all channels ?
Not at this time, but it could be implemented ... any real particular needs targeted with this implementation ?
 
> In your example 'this' will receive the 'click' event 3 times from the same source, is there a way to know witch channel the event came from ?
No, but I can update addEventListener method like shown below to provide auto-delegate factory.
 
public function addEventListener( type : String, o : Object, oChannel : String ) : Void
 ;{
  var eb : EventBroadcaster = getChannelDispatcher( oChannel );
  var args : Array = arguments.splice( 0, 2 ).concat( arguments.splice( 3 ) );
  eb.addEventListener.apply( eb, args );
 }
 
Another solution would be to extend BasicEvent to have getChannel() accessor.
But indeed, I think that won't be a good implementation, coz you'd need to clone your events, give the responsibility to ChannelBroadcaster to inject channel information, and last but not least you'd lose polymorphism with inherited classes from BasicEvent.
So that's a bad idea at all.
 
> Why as much secret ? ^^
It's not really so secret, I just don't wanna tease about features that won't be available at the end of this project. ;)
 
francis
 
----- Original Message -----
Sent: Sunday, November 26, 2006 2:48 PM
Subject: Re: [Pixlib] ChannelBroadcaster example

Hi Francis,
Pixlib type="cite">
Hello guys,
 
that's a concept I made for LowRA.
It's in pixlib now coz I need it for the upcoming extension based on IoC pattern.
 
Here's a quick example to illustrate tv channels metaphor:
 
var cb : ChannelBroadcaster = new ChannelBroadcaster();
cb.addEventListener( "click", this, "gameone" );
cb.addEventListener( "click", this, "mtv" );
cb.addListener( this, "france4" );
cb.broadcastEvent( new StringEvent( new EventType("click"), "gameone" ), "gameone" );
cb.broadcastEvent( new StringEvent( new EventType("click"), "mtv" ), "mtv" );
cb.broadcastEvent( new StringEvent( new EventType("click"), "france4" ), "france4" );

Thanks for the example
Pixlib type="cite">
I didn't see this event pattern somewhere at this time, did you ?
We've built something approaching for our Drag&Drop engine within the Blob, each object can interact in several
channel, in order to have a really flexible and powerful interactivity. But your implementation is so much reusable , I think I
will play a lot with it ;).

Some questions :

- Is there a way to broadcast an event to all channels ?
- In your example 'this' will receive the 'click' event 3 times from the same source, is there a way to know witch channel the event came from ?
Pixlib type="cite">
I got this idea from my multi-users work, I like a lot room communication concept.
I hope you'll like it, and I'm pretty sure you'll enjoy it in the scope of the release of pixlib extension.
Why as much secret ? ^^

Cédric


_______________________________________________
Pixlib mailing list
Pixlibosflash.org
http://osflash.org/mailman/listinfo/pixlib_osflash.org
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )