我想在shortest
中添加最短的int:
shortest = 500;
for(i = 1; i <= _global.var_process_count; i++)
{
if(_root["process" + i].process_time_original.text < shortest)
shortest = _root["process" + i].process_time_original.text ;
}
上面的代码行有什么问题?
答案 0 :(得分:2)
textfield.text
)投射到Number
。请尝试以下代码:
var shortest:Number = Number.MAX_VALUE;
for(i = 1; i <= _global.var_process_count; i++)
{
var t:Number = Number(_root["process" + i].process_time_original.text);
if(isNaN(t)) //in case the text is not a valid number.
continue;
if(t < shortest)
shortest = t;
}
trace("shortest number is " + shortest);