Yes, I'd be happy to share :)
 
#1) I just want to know how to do it, to put my mind at ease that I can
do this if I DO ever have the need
 
#2) The reason it's in my modelLocater is because, my debugText variable
is held here - and I have a floating Debug Window which stays open
during the development phase of my application.  In my Debug Popup
Window, I simply have a TextArea Control, in which I bind the
model.debugText variable to.  Then whenever I want to perform a trace, I
just run my "model.updateDebug()" function, which in turn, appends any
new Debug Information, to the model.debugText variable.  And voila! my
Debug Window gets updated with the debugText.
 
#3) Any time Text is added to a TextArea control, and the text size
exceeds the currently displayed limit, ScrollBars appear - and any
additional text added, gets placed below the visible area.  With the
nature of the Text being debugging information, I am most interested in
ONLY the latest text being added - so I need to automatically scroll my
TextArea all the way to the bottom.  I want within my grasp, the ability
to manually dispatch the event, which causes my TextInput Control to
scroll all the way to the bottom.
 
#4) I know that I could simply create an event listener for the TextArea
residing in my DebugWindow, that any time a "change" event occurs, to
run a function that causes the ScrollBars to move all the way to the
bottom.
 
So with all that said, I guess bottom line, I am asking this:
 
How can I write BOTH, and Event listener to listen for events, and ALSO
an Event Dispatcher to dispatch the event, whereas I can ANYWHERE inside
of my application, trigger this to happen any time I like??
 
I was under the impression, that Events get broadcasted "Application
Wide" - and that anything with an active listener running, will capture
and respond to the event.  I guess I was sadly mistaken, because I am
hitting a MAJOR brick with all of this.
 
I would love to hear more input on this topic :)
 
Thanks,
 
Mike

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Sam Shrefler
Sent: Tuesday, January 09, 2007 7:19 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] Dispatching an Event from a Class


Mike, I'm interested in why you would dispatch an Event from your
modelLocator?  Could you please share?
 
Also, could this be a case where the Observe tag could help you?
 
 
http://weblogs.macromedia.com/paulw/archives/2006/05/the_worlds_smal.cfm

Thanks

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

        
        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 <http://ups.com/>  [mailto:
flexcoders@ <mailto:flexcoders@> yahoogroups.com] On Behalf Of Sergey
Kovalyov
        Sent: Tuesday, January 09, 2007 1:28 PM
        To: [EMAIL PROTECTED] ups.com <http://ups.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