English 中文(简体)
行动说明 3 - 检测点到zo或rag
原标题:Actionscript 3 - detecting click to zoom or drag

我使用行动文件3,正在建设图像观众。 至今,我有以下功能:

1) When viewing the normal sized image, clicking will display a "zoomed" image.
2) When viewing the zoomed image, clicking will display the "normal" image.

.。

现在,我想采取下列行为,使用户能够 around清和rag弄 around骨头的图像,并概括如下:

1) Removed the onClick event
2) Add an "onMouseDown" event, to record the mouse XY on mouse down
3) Add a "onMouseUp" event, and record the mouse XY on mouse up
4) If the XY onMouseDown = XY onMouseUp then assume a Click event - so Zoom
5) If the XY onMouseDown != XY onMouseUp then assume a Drag event - so drag the image

现在,只有用户在点击时有稳定的手,才会奏效,而且没有像一个伟大的解决办法。 如果用户手不可靠,那么当他们真的想要去掉头脑时,就算发生了一件 d事。

谁能提出比我上文所列举的更妥善的办法来检测到如何改变形象或使形象?

感谢您的想法/帮助,

Senior coconut.

最佳回答

基本假体编码如下:

import flash.utils.getTimer;

private var clickTime:uint;

function onMouseDown(event:Event):void {
    this.clickTime = getTimer();

    // Start drag even if they intend to zoom -- it won t hurt if it shifts a
    // couple pixels before zooming out
    startDrag();
}

function onMouseUp(event:Event):void {
    var delta = getTimer() - this.clickTime;

    // It s been less than a quarter second, so user probably meant to zoom
    // in/out.  Adjust this number to taste if it seems too low or high.
    if (delta < 250)
        toggleZoom();

    stopDrag();
}
问题回答

暂无回答




相关问题
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 ...

热门标签