嘿伙计们,我想问你们,你们会怎么做,因为我是编程新手,我仍在努力弄清楚如何做到这一点。
我正在建立一个带空气的应用程序,我有几个带开关盒的按钮。
现在我的所有按钮都是动画片段按钮,因此当您点击它们时,它们会转到点击的图像并返回到图像。
加上一些按钮我希望有一个长按功能,可以更快地增加。
我希望我在这里有任何意义
这是我的一些加号和减号按钮
master.pages.numPlayers.minusBtn1.addEventListener(MouseEvent.CLICK, incrementAmount);
master.pages.numPlayers.plusBtn1.addEventListener(MouseEvent.CLICK, incrementAmount);
master.pages.numBuyIns.minusBtn2.addEventListener(MouseEvent.CLICK, incrementAmount);
master.pages.numBuyIns.plusBtn2.addEventListener(MouseEvent.CLICK, incrementAmount);
master.pages.numPayouts.minusBtn3.addEventListener(MouseEvent.CLICK, incrementAmount);
master.pages.numPayouts.plusBtn3.addEventListener(MouseEvent.CLICK, incrementAmount);
这是带有我的开关案例的函数处理程序我希望这些按钮有两种类型的行为,长按增量更快,只是逐个定期点击增量
private function incrementAmount(event:MouseEvent):void {
switch (event.currentTarget.name) {
// number of players
case "minusBtn1" :
if (numPlayers >= 3) {
numPlayers--;
firstBuild();
trace("minus");
}
break;
case "plusBtn1" :
numPlayers++;
firstBuild();
trace("plus");
break;
// number of buy ins money
case "minusBtn2" :
if (numBuyIns >= 1) {
numBuyIns--;
firstBuild();
trace("minus");
}
break;
case "plusBtn2" :
numBuyIns++;
firstBuild();
trace("plus");
break;
// number of payouts
case "minusBtn3" :
if (numPayouts >= 2) {
numPayouts--;
firstBuild();
trace("minus");
}
break;
case "plusBtn3" :
numPayouts++;
firstBuild();
trace("plus");
break;
}
}
其他具有常规点击行为的按钮
private function onClickTab(event:MouseEvent):void {
switch (event.currentTarget.name) {
case "chips" :
master.pages.x = 20;
break;
case "payout" :
master.pages.x = -704;
break;
case "timer" :
master.pages.x = -1457;
break;
}
}
答案 0 :(得分:0)
public class PlusButton extends Button
{
private var m_blnSpedUp:Boolean = false;
private var m_tmr:Timer = new Timer(1500, 1); // use whatever number of
// milliseconds you prefer here
public function PlusButton()
{
addEventListener(MouseEvent.DOWN, onDown);
addEventListener(MouseEvent.UP, onUp);
}
private function onDown(pEvent:MouseEvent):void
{
// increment here
if (!m_blnSpedUp)
{
// start the timer here
}
}
private function onUp(pEvent:MouseEvent):void
{
// stop the timer here
}
private function tick(pEvent:TimerEvent):void
{
m_blnSpedUp = true;
// speed up here
}
}
如果我理解你的问题,希望这会让你开始。尝试以此为出发点。