We'd need to see a test case to see how you hooked up the listener

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Derrick Anderson
Sent: Friday, February 29, 2008 7:14 AM
To: [email protected]
Subject: [flexcoders] Re: putting event listeners on non UIComponent
classes

 

anybody have any ideas on this one?

         

        i'm trying to put an event on a TextRange object and having some
issues.  I know that natively I cannot add events to TextRange objects,
so I googled and found a way of doing it. The goal is to be able to put
a tooltip or  show an element when somebody mouses over a certain
textrange in a text field, however the event is not firing on mouseover
and not sure why
        
        I have LCTextRange.as and CustomEventDispatcher.as and it
inherits like this:
        
        LCTextRange -> CustomEventDispatcher->TextRange
        
        I am creating a new LCTextRange instance like so:
        
        var tr:LCTextRange = new LCTextRange(textArea, false,
textArea.text.indexOf(item, prevEndIndex), textArea.text.indexOf(item,
prevEndIndex)+item.length);
        
        My events are not firing and not sure why, here's what I've
done.
        
        LCTextRange.as
        
        public class LCTextRange extends CustomEventDispatcher
            {
                override public function LCTextRange(owner:UIComponent,
modifiesSelection:Boolean=false, beginIndex:int=-1, endIndex:int=-1)
                {
                    super(owner, modifiesSelection, beginIndex,
endIndex);
                    this.addEventListener(MouseEvent.CLICK,showToolTip);
//CLICK is here for testing
                }
                
                private function showToolTip(e:Event):void
                {
                    Alert.show('over');
                }
            }
        
        and here is the CustomEventDispatcher.as
        
        public class CustomEventDispatcher extends TextRange implements
IEventDispatcher
            {
                private var eventDispatcher:EventDispatcher;
                
                public function CustomEventDispatcher(owner:UIComponent,
                                      modifiesSelection:Boolean = false,
                                      beginIndex:int = -1, endIndex:int
= -1)
                {
                    super(owner,modifiesSelection,beginIndex,endIndex);
                    eventDispatcher = new EventDispatcher(this);
                }
        
                public function addEventListener(type:String,
listener:Function, useCapture:Boolean=false, priority:int=0,
useWeakReference:Boolean=false):void
                {
                    eventDispatcher.addEventListener(type, listener,
useCapture, priority, useWeakReference);
                }
        ....... and all the other IEventDispatcher functions.
        
        

 

 

Reply via email to