DropDownList does not dispatch close event, when click outside - actionscript-3

When I click on stage outside the opened DropDownList, somehow the close event does not dispatch. How can I force it to dispatch this event after clicking anywhere outside the DropDownList?
Or Let me ask my question through another way:
Imagine we have 2 states and when clicking outside the opened DropDownList, the state 1 will change to state 2. During this process how can be sure DropDownList closed completely and close event dispatched? And if not force it to close!
P.S 1: DropDownList.closeDropDown(true); does not force it to dispatch close event too!
P.S 2: Sorry didn't share any code, I have all of them in separated classes and was hard to share them here :D But I think in total the problem is understandable. I want force my DropDownList to dispatch close event whenever I'm clicking outside it.

do a manual dropdownlist.dispatchEvent( new Event( Event.Change ) ); :D

Through the stateChangeCompleteHandler tried this:
DropDownList.dispatchEvent(new DropDownEvent(DropDownEvent.CLOSE));
P.S: TanQ #Discipol for his point

Related

React state based on mouse/keyboard press/release

i'm creating a custom button with React.
The appearance based on the press/release of the mouse/keyboard.
Sometimes it cannot be done by css using :active pseudo, so i need the javascript solution.
So i created a state that listen the onMouseDown/Up & onKeyDown/Up.
The problem is, if the user click the button then drag the mouse out of the button then release the mouse,
i miss the onMouseUp event thus causing the activeState locked up forever.
Do you have a solution for the equivalent of the :active & :not(:active) pair in javascript way?
note:
watching event window.addEventListener('mouseup',...) is still not satisfying me. When the mouse click hold & move out from the browser's window, i still missing the mouseup event.

AS3 Making a button work on one scene and does nothing on all other scenes.

I basically have 50 buttons and 50 scenes. Each scene has a corresponding button that is "correct". When a user clicks the correct button, I want it to go to the next scene AND also make that button not-clickable anymore. I have everything functioning except for the not-clickable part and this is an issue because whenever i click on a state that already has been selected as the right answer, it'll jump me back to the question that was supposed to follow it. I'd show my code, but it is just 50 buttons and a buttonClick function and that's it.
Thanks in advance.
You could call
yourButton.removeEventListener(MouseEvent.CLICK,yourFunction);
or you could call
yourButton.mouseEnabled = false;
yourButton.mouseChildren = false;
Hard to help without any code.

ActionScript 3 keyboard event not firing after button click

I'm building a simple game in which you control the character with W A S D keys. When you die, you go to another frame that says you died and has a button to play the game again. When I click the button, it goes to the frame 1 again, but the keyboard events don't work unless I click once more on the screen. How can I solve this? Thanks in advance.
On your frame1 try adding an active listiner to set the focus:
activate="this.setFocus()"
I couldn't get your question clearly. If once you click on that button it is working correctly right. If the way which i have understood is correct there might be problem on your looping or condition. please let me know your coding here, I will try to resolve. else check yourself the looping or condition on the frame1 or where you wrote your keybord event listener. I hope it will be usefull else please let me know i will give you another solution.

Page flip effect on button press in html5

I'm looking at this:
http://www.netmagazine.com/tutorials/create-page-flip-effect-html5-canvas
However, I have one problem with that - I need to be able to click on the pages, even the edges, without triggering the page turn. I want the pages to turn when a button outside of the canvas is pressed. Is this possible using the base they provided, or do I need to go an entirely different direction?
Yes that can be done.
From what i can see, you need a click event that doesnt trigger the page drag. You need to assign a flag for this.
Let Drag = mouse drag/mouse move, down = mouse down, release = mouse release events respectively.
Initialize your flag variable as false. When a drag event is encountered it becomes true. Otherwise it remains false. As long as it is false when the mouse release event occurs it can be treated as a click. Thats the basic principle behind using mousedown and mouseup as a click event.
You will have to use e.srcElement or e.target to give you the element your cursor is currently positioned over inorder to trigger click functions relative to that element.
If you want a more detailed explanation on the page flip technique then check this out. Helped me lot.

Button removed with removeChild() gets re-added in it's over state

I have a SimpleButton on the stage, and in the click event for it, I remove it using removeChild(). When re-adding the button, it gets re-added in it's "over" state, not the "up" state as expected.
I'm pretty sure it's a bug, so I've filed a JIRA: http://bugs.adobe.com/jira/browse/SDK-31445, my question is now on how to fix it, if anybody's had a similar experience.
What I've tried:
using visible = false instead works, but I'd prefer to remove it off the stage altogether as the game I'm working on can have a lot of popups/screens.
Firing the mouse_out event manually - doesn't work, and in any case, the mouse_out event fires as expected (perhaps before resetting to the up state, it makes a check to see if it's added to the stage, finds out it's not, then quits early)
Resetting the stage focus - I thought it was a problem with the stage focus, as you were losing focus when the button was hidden, but resetting it didn't fix it.
I could temporarily swap the over and up state when it's hidden, but that seems like an ugly fix.
I've been Having this problem as well, removing one button and adding another in response to an Mouse up event on a separate sprite.. IE the mouse isn't over either of the buttons at the time, But when the first button (the one with the problem) was previously removed the mouse was indeed over it so it hadn't received a mouseOut event and retained itself in the over state. Using visibility to work round this which is ok for my needs BUT the alternative answer would be to replace with a new instance of the button before adding it to the Display List.