You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flex.apache.org by "Alex Harui (JIRA)" <ji...@apache.org> on 2013/08/12 07:55:47 UTC

[jira] [Resolved] (FLEX-33662) Events not removing

     [ https://issues.apache.org/jira/browse/FLEX-33662?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alex Harui resolved FLEX-33662.
-------------------------------

    Resolution: Not A Problem

This is by design.  Flex/Flash uses DOM Events, and all DOM event handlers require a parameter that is the event object.  Adobe decided that it was more important to allow folks to write event handlers without requiring them to write a function header with a parameter or name a function in the MXML attribute for the event than it was to allow folks to remove that event handler.  Also note, there are often other hidden references to MXML objects created by the compiler.

IOW, the following event handlers are allowed in MXML
    click="trace('foo')"
and
    click="someFunction()"
where
    <fx:Script>
    private function someFunction():void
    {
    ....
    }
    </fx:Script>

In the second example, someFunction is not the listener.  IOW, it is not passed into addEventListener.  Instead, the MXML compiler creates a wrapper for someFunction with an obscure name like:
    private function button01_click(event:Event):void
    {
        someFunction();
    }

If the MXML compiler did not wrap someFunction, then you would be required to put an event parameter on someFunction, and if you got the type of the event wrong you would get a hard-to-debug error. 

There might be some way to see if the event handler is a single function call with an event parameter and not wrap it, but unless we see a lot of votes for it, I don't think it will happen
                
> Events not removing
> -------------------
>
>                 Key: FLEX-33662
>                 URL: https://issues.apache.org/jira/browse/FLEX-33662
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: Spark: List
>    Affects Versions: Apache Flex 4.11.0
>            Reporter: Sateesh Jaladi
>         Attachments: Main-generated.as, Main.mxml
>
>
> Events added as part of mxml can not be removed.  Even some of the events come default without creating them.  Add a list component and create handler for "applicationComplete" event in application tag and check if the list component is having event listener for "change", (using hasEventListener(Event.CHANGE)) it will exist even though I haven't added one.  Apart from this, If I add "changing" in List mxml like <s:List id="list" changing="changingHandler()" />, I cannot remove the listener for "changing" event, even if I  try to remove and test to see the same by using "hasEventListener('changing')" with the list component, its returning "true" only and never "false".  The generated actionscript gives a hint like its creating own listeners and if we use the same listener to remove in application we see the output for "hasEventListener('changing')" is false.
> Files has been added for your reference, you will have better idea once you check the attached files.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira