I just want to mention... 
 
The name of the autogenerated event handler method for an MXML event
attribute is an undocumented implementation detail that is subject to
change without notice in future versions of Flex.
 
Also, I'm curious what you're trying to accomplish by removing these
listeners.
 
- Gordon

________________________________

From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Firdosh Tangri
Sent: Friday, September 14, 2007 9:20 AM
To: [email protected]
Subject: Re: [flexcomponents] Removing Events defined by MXML



Hey Josh,
               thanks well I an working on a big project and a lot of
creation complete and other mxml defined events are there

I used a hack to kill the eventlistener 

basically just did  a 

var comp:UIComponent = event.currentTarget as UIComponent;
comp.removeEventListener(MouseEvent.CLICK,
Application.application["__btn_click"];

so there is 2 underscore , the id of the component in this case "btn"
and then underscore again and then the event name , which is click here 


and that basically took care of the problem.

cheers
firdosh



On 9/14/07, Josh Tynjala <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
wrote: 

        As far as I know, it's not possible to remove events of this
type. The Flex compiler actually generates a function to wrap around
whatever you call. You can see the exact code if you look at the
generated code using the -keep compiler argument, but it looks something
like this:
        
        private function
someGeneratedFunctionName(event:MouseEvent):void
        {
            //your code gets copied here
            onClick();
        }
        
        You can get an idea of why when you think of the fact that the
"event" parameter is available in your click="" attribute in the MXML.
You can either pass it to your function or ignore it completely. In
ActionScript, when you use addEventListener instead, your function must
always accept an event parameter.

        
        
        Firdosh Tangri wrote: 

                hey all,
                            I was just wondering if i define an event by
mxml like
                <mx:Button id="myBtn" click="onClick();") />
                
                and then try and remove it
                
                private function onClick():void{ 
                    trace("Click");
                    myBtn.removeEventListener(MouseEvent.CLICK,
onClick);
                }
                
                it still keeps calling the function but if i add the
event listener through as
                
                like 
                
                myBtn.addEventListener (MouseEvent.CLICK , onClick);
                
                then it removes the call back function.
                
                thanks
                cheers
                firdosh
                
                
                
                


        

        


 

Reply via email to