Right Eric, this was a quick and dirty example.

Another thing to note: Event bubbling is dangerous.

Only make your event bubble if it is absolutely necessary.

I have made some big components and learned the hard way. :)

This is just my opinion but event bubbling almost breaks OOP encapsulation.
If there is a chance some instance that has not 'subscribed' to your api
gets your event, BUGS happen. This problem is synonymous to name collisions
and since the compiler can't type check events, here in lies the problem.

This can also hurt a dev that does not truly understand bubbling and is
trying to use your component or application.

Mike

On Sat, Jun 14, 2008 at 9:40 AM, EECOLOR <[EMAIL PROTECTED]> wrote:

>   Whenever you create a custom event. Make sure you override the 
> *clone*method. If you do not do that you will get strange results when
> re-dispatching an event.
>
>
> Greetz Erik
>
>
> On 6/12/08, Michael Schmalle <[EMAIL PROTECTED]> wrote:
>>
>>  Hi
>>
>> package my.event.package
>> {
>>
>> public class MyEvent extends Event
>> {
>>     public static const IS_GREATER_CHANGED:String = "isGreaterChanged";
>>
>>     public var isGreater:Boolean;
>>
>>     public function MyEvent(type:String, isGreater:Boolean)
>>     {
>>         super(type);
>>         this.isGreater = isGreater;
>>     }
>> }
>> }
>>
>> // app as file
>>
>> [Event(type="isGreaterChanged", type="my.event.package.MyEvent")]
>>
>> ...
>>
>> var e:MyEvent = new MyEvent(MyEvent.IS_GREATER_CHANGED, true);
>> dispatchEvent(e);
>>
>> ... event handler
>>
>> private function isGreaterHandler(event:MyEvent):void
>> {
>>     trace(event.isGreater);
>> }
>>
>> Mike
>>
>
>  
>



-- 
Teoti Graphix, LLC
http://www.teotigraphix.com

Teoti Graphix Blog
http://www.blog.teotigraphix.com

You can find more by solving the problem then by 'asking the question'.

Reply via email to