我正在使用Actionscript 3而不是在做类,只有每个面板的actionscript。我正在尝试创建一个角色创建屏幕,告诉玩家在将它们添加到六个类别中的一个之后他们剩下多少点。分数正在起作用,但是更新玩家的部分是关于他们剩下的分数是不是。我需要它不断更新,告诉玩家剩下多少分。
var score=0;
var strscore=1;
scorenum.text= update(score); //How I want it displayed.
function update(score) //Brings in the score variable
{
while(score<66) //As you can see I'm trying to make it constantly call here.
//No Good. Calls once.
{
trace("update Score "+score)
var num= 65-score;
scorenum.text= num;
return num;
}
}
strMinus.addEventListener(MouseEvent.CLICK, strMinusFn);
function strMinusFn(event:MouseEvent)
{
if (score<=59)
{
if (strscore >1 && strscore<=50)
{
strscore--;
score--;
}
else
{
strscore==strscore;
}
}
sX.text=strscore;
return score;
}
strPlus.addEventListener(MouseEvent.CLICK, strPlusFn);
function strPlusFn(event:MouseEvent)
{
if (score<=58)
{
if (strscore >=1 && strscore<50)
{
strscore++;
score++;
}
else
{
strscore==strscore;
}
}
sX.text=strscore;
return score;
}
var dexscore=1;
dexMinus.addEventListener(MouseEvent.CLICK, dexMinusFn);
function dexMinusFn(event:MouseEvent)
{
if (score<=59)
{
if (dexscore >1 && dexscore!=50)
{
dexscore--;
score--;
}
else
{
dexscore==dexscore;
}
dX.text=dexscore;
}
return score;
}
dexPlus.addEventListener(MouseEvent.CLICK, dexPlusFn);
function dexPlusFn(event:MouseEvent)
{
if (score<=58)
{
if (dexscore >=1 && dexscore<50)
{
dexscore++;
score++;
}
else
{
dexscore==dexscore;
}
dX.text=dexscore;
}
return score;
}
var intscore=1;
intMinus.addEventListener(MouseEvent.CLICK, intMinusFn);
function intMinusFn(event:MouseEvent)
{
if (score<=59)
{
if (intscore >1 && intscore!=50)
{
intscore--;
score--;
}
else
{
intscore==intscore;
}
iX.text=intscore;
}
return score;
}
intPlus.addEventListener(MouseEvent.CLICK, intPlusFn);
function intPlusFn(event:MouseEvent)
{
if (score<=58)
{
if (intscore >=1 && intscore<50)
{
intscore++;
score++;
}
else
{
intscore==intscore;
}
iX.text=intscore;
}
return score;
}
var conscore=1;
conMinus.addEventListener(MouseEvent.CLICK, conMinusFn);
function conMinusFn(event:MouseEvent)
{
if (score<=59)
{
if (conscore >1 && conscore!=50)
{
conscore--;
score--;
}
else
{
conscore==conscore;
}
cX.text=conscore;
}
return score;
}
conPlus.addEventListener(MouseEvent.CLICK, conPlusFn);
function conPlusFn(event:MouseEvent)
{
if (score<=58)
{
if (conscore >=1 && conscore<50)
{
conscore++;
score++;
}
else
{
conscore==conscore;
}
cX.text=conscore;
}
return score;
}
var wisscore=1;
wisMinus.addEventListener(MouseEvent.CLICK, wisMinusFn);
function wisMinusFn(event:MouseEvent)
{
if (score<=59)
{
if (wisscore >1 && wisscore!=50)
{
wisscore--;
score--;
}
else
{
wisscore==wisscore;
}
wX.text=wisscore;
}
return score;
}
wisPlus.addEventListener(MouseEvent.CLICK, wisPlusFn);
function wisPlusFn(event:MouseEvent)
{
if (score<=58)
{
if (wisscore >=1 && wisscore<50)
{
wisscore++;
score++;
}
else
{
wisscore==wisscore;
}
wX.text=wisscore;
}
return score;
}
var chascore=1;
chaMinus.addEventListener(MouseEvent.CLICK, chaMinusFn);
function chaMinusFn(event:MouseEvent)
{
if (score<=59)
{
if (chascore >1 && chascore!=50)
{
chascore--;
score--;
}
else
{
chascore==chascore;
}
hX.text=chascore;
}
return score;
}
chaPlus.addEventListener(MouseEvent.CLICK, chaPlusFn);
function chaPlusFn(event:MouseEvent)
{
if (score<=58)
{
if (chascore >=1 && chascore<50)
{
chascore++;
score++;
}
else
{
chascore==chascore;
}
hX.text=chascore;
}
return score;
}
答案 0 :(得分:0)
您可以使用while循环,每次将分数放入“属性”时都会更新余数。
的内容
while score > 0
if attribute_variable > variable_counter
score -= 1
variable_counter += 1
因此,while循环将检查您是否有任何分数放入您的属性。 if语句将检查您是否在特定属性中添加了一个点,if中的语句是更新该特定计数器的分数和计数器,以便计数器识别出您已在该变量中添加了一个点。 / p>