views:

137

answers:

1

I'm maintaining a ActionScript 2 application which uses createEmptyMovieClip to create dropdown lists (the list items being attached as movieclips). I can close the dropdown directly via removeMovieClip and such, obviously.

My problem is this: the dropdown should not only be closed when an item is clicked or the button creating it is triggered again, but also anytime the user clicks anywhere outside the dropdown (like onReleaseOutside, except the click also STARTS outside).

So far the only solution I can see is turning _root (or an invisible layer) into a button by proving an onRelease for it, but that's hackish in that it makes _root be treated like a button by Flash (pointer mouse cursor and all that). Do not want!

+1  A: 

I was just about to recommend you do what you don't want to do, because it is hackish. Setting up a mouse listener might be an option...(I drew [mc] on really quickly...)

MouseListener = new Object()
Mouse.addListener(MouseListener)
MouseListener.onMouseDown=function(){
    trace ("heard:'DOWN'")
    // do your call to close the button here, perhaps?
}

another.onPress=function(){
    trace ("pressed!")
}

I cant think of a better way just yet...

The above code doesnt fix much, but it shows that you can listen for the click as well as do something relative to what you clicked and for them be two separate actions.

Assembler