本文介绍了你将使用什么来在Flex / AS3中填充一个数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
b $ b var ret:String =+ number;
while(ret.length ret =0+ ret;
return ret;
}
Duplicate of this one.
What would you use to pad zeroes to the left of a number in Flex/AS3?
Is there an equivalent to printf
or NumberFormat
that does this?
I'm looking for the nicest implementation of this or something similar:
public function zeroPad(number:int, width:int):String {
// number = 46, width = 4 would return "0046"
}
解决方案
public function zeroPad(number:int, width:int):String {
var ret:String = ""+number;
while( ret.length < width )
ret="0" + ret;
return ret;
}
这篇关于你将使用什么来在Flex / AS3中填充一个数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!