English 中文(简体)
纽芬兰
原标题:problems with buttons in as3

i have two buttons, each half the width of the screen and both the entire height of the stage. So one button would be on the left of screen and the other, the right. I have eventlisteners for both when the buttons are pressed and released.
My problem is that if i click one button and drag to the other side, the event take it that the mouse is not released.
For example the right button should make my character fly, so when i click on it, it flies and if i drag my mouse to the left button and release, my character continues flying. I believe this is due to the right button being unable to detect the mouse up when its off the button shape. Is there any way around it?

最佳回答

评 注

<代码>MouseEvent。 MemorandumSE_OUT

When you start dragging (MOUSE_DOWN) set a isCurrentlyDragging boolean to true (defined outside of the event handler function of course). On MOUSE_OUT if it is currently dragging then decide wether to handle it as a MOUSE_UP.

On MOUSE_UP and on MOUSE_OUT set isCurrentlyDragging = false;

问题回答

这在AS2中很容易发现,但是(出于某种原因)在AS3中将其删除。

我这样做是为了增加全球的 mo。 更新名单;

stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
function mouseUpHandler(e:Event) {
  if( _clickedObject ) _clickedObject.dispatchEvent(new Event("releasedOutsideEvent"));
}

之后,在我的备忘录中, DOWN 操作员

_clickedObject = e.target;

and in the MOUSE_UP handler

_clickeObject = null;

或像这样的东西。 可能会有两点左右,但应该工作。





相关问题
Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签