Muhammad Umar
Muhammad Umar

Reputation: 11782

how to stop getting mouse click events in flex

I have made a hierarchy in which there is a main page, using add element i have attached a component mxml of type group. There is a single button on main page when clicked it should add children of type group in that group type mxml component along with two buttons. Now using one of buttons i am attaching another component mxml type group. the problem is even they overlap i can still excess the children groups of first group component mxml. how can i stop this mouse events to happen.

Upvotes: 1

Views: 1747

Answers (2)

Michiel Standaert
Michiel Standaert

Reputation: 4176

By setting enabled, mouseChildren, mouseEnabled to false, you will disable the entire component and it's children. example below

private var myPreviousGroupComponent:Group = null;
function addNewGroup():void
{
    if(myPreviousGroupComponent != null)
    {
        myPreviousGroupComponent.enabled = false;
        myPreviousGroupComponent.mouseChildren = false;
        myPreviousGroupComponent.mouseEnabled = false;
    }

    var newGroup:Group = new Group();
    addElement(newGroup);

    myPreviousGroupComponent = newGroup;
}

Upvotes: 1

Anton M
Anton M

Reputation: 100

I think those kind of events usually bubble up to parent components. You can try using the following code in your mouse click event listener to stop further propagation:

private function onMouseClicked(event: MouseEvent): void {
    event.stopPropagation();
    ... do whatever you wanted when smth was clicked ...
}

Upvotes: 1

Related Questions