Yes, I understand this -
 
But what about a generic class, that does NOT extend any other classes
(which have the IEventDispatcher as part of their makeup)
 
In my generic class (in this case, my ModelLocater which is part of a
Cairngorm-based application), it doesn't natively have anything in there
which includes the EventDispatcher stuff.
 
So, I wanted to see what the bare minimum requirements would be, in
order to Dispatch an Event from a Class File that doesn't "extend" or
"implement" anything else.
 
Also, I DO have the [Bindable] Metatag on this class, and even know I
don't get any code-hinting whenever I type any "dispatchEvent" type
code, I don't get any Compiler Errors either...  That struck me as odd,
but with what Tracy just mentioned, it does answer a few questions...
 
So I guess, the [Bindable] Metatag is a quick way to add this
functionality, but I am just curious if I wanted to accomplish this via
some other means.
 
Thanks for the info on this topic :)
 
Mike

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sergey Kovalyov
Sent: Tuesday, January 09, 2007 1:28 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dispatching an Event from a Class


Just call dispatchEvent() (e. g. dispatchEvent(new Event(Event.CHANGE)))
in any class that implements IEventDispatcher (e. g. all the
EventDispatcher successors). Note, that UIComponent and all its
successors implement IEventDispatcher, so dispatchEvent() could be
called in any subclass of Box, ComboBox, Label, TextArea, HSlider, etc: 
 
package {

 import mx.controls.HSlider;

 public class MyHSlider extends HSlider {

  public function MyHSlider() {
   super();
   
   dispatchEvent(new Event("instanceConstructed"));
  }
  
 }

}

On 1/9/07, Mike Anderson <[EMAIL PROTECTED]> wrote: 

        Hello All,
        
        I am attempting to dispatch an Event from a generic Class File,
and I
        guess I'm not doing it correctly.
        
        I was hoping, that I could simply do this:
        
        import mx.events.IEventDispatcher 
        
        And then in my function, I could simply dispatch the event like
this:
        
        IEventDispatcher.dispatchEvent( event );
        
        But it doesn't allow me to do this. In the meantime, I extended
my
        Class to use the UIComponent, which automatically pulls in all
the 
        EventDispatcher stuff. Of course, it's silly for me to do this,
since I
        really don't have a need to extend the UIComponent class.
        
        There must be a way, to import the proper Class, in order to
simply
        dispatch events.
        
        Any advice?
        
        Thanks in advance for your help,
        
        Mike
        

        


 

Reply via email to