【问题标题】:Actionscript While loop & addChild problemsActionscript While 循环和 addChild 问题
【发布时间】:2014-03-20 01:58:26
【问题描述】:

您好,我正在尝试制作一个幂计算器,以显示我的 actionscript3 代码中由 while 循环计算的每一行。当我运行程序时,flash 文件只显示最后一个循环,任何人都可以在不使用跟踪的情况下帮助它工作吗?我需要它显示在 Flash 程序中。这是我的代码:

private function evalue(event:MouseEvent = null):void 
{ 
maMiseEnForme.font="Arial"; 
maMiseEnForme.size=14; 
maMiseEnForme.bold=true; 
maMiseEnForme.color=0x000000; 
monMessage.x=270; 
monMessage.y=375; 

monMessage.autoSize=TextFieldAutoSiz... 
monMessage.border=true; 
monMessage.defaultTextFormat=maMiseE... 

var base:uint; 
var reponse:uint; 
var puissanceCount:int=1; 
var puissance:uint; 
var reponseText:String; 


base = uint(boiteBase.text); 
puissance = uint(boitePuissance.text); 
while (puissanceCount <= puissance) 
{ 
reponse = Math.pow(base,puissanceCount); 
reponseText=(base + "^" + puissanceCount + "=" + reponse + "\n"); 
monMessage.text=reponseText; 
addChild(monMessage); 
puissanceCount++ 
} 
} 
} 
}

我附上了 .swf 窗口中显示的图片:

P.S:我是闪光灯的新手。

提前致谢。

【问题讨论】:

    标签: actionscript-3 flash while-loop addchild


    【解决方案1】:

    您可以使用“+=”参数而不是“=”参数通过“向其添加字符串”而不是“每次刷新”来更新字符串变量,然后您可以在 while 循环完成后显示文本。您不需要在everyloop 中添加Child(nonMessage),只需在while{} 循环之后移动它即可。所以:你只需要“monMessage.text+=reponseText;”而不是“monMessage.text=reponseText;”并将你的“addChild()”移动到你的while循环旁边。

    【讨论】:

      猜你喜欢
      • 2011-06-07
      • 2011-06-19
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      • 2014-11-22
      • 1970-01-01
      • 2018-11-05
      相关资源
      最近更新 更多