As3加速度测试

[code]stage.addEventListener(MouseEvent.MOUSE_DOWN,doClick);
stage.addEventListener(MouseEvent.MOUSE_UP,doClick2);
addEventListener(Event.ENTER_FRAME,doE);
var clicked:Boolean = false;
var vx:Number = 0;
var ax:Number = .2;
function doClick(e:MouseEvent):void
{
clicked = true;
}
function doClick2(e:MouseEvent):void
{
clicked = false;
}

function doE(e:Event):void
{
test.x = mouseX;
if (! clicked)
{

vx += ax;
test.y += vx;
}
else
{
vx -= ax;
test.y += vx;
}

}[/code]

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>