本文介绍了一个整数转换为字符串AS3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何转换一个整数为字符串值?这肯定是容易的。 雅家伙SO是个大最好的解释。我仍然在这些愚蠢的计数器。
需要加入此一并
//我的柜台项目发送到动态文本字段
VAR定时器:定时器=新的定时器(10);
VAR计数:= 0; //为-1开始,如果你想小数点后第一位为0
VAR FCOUNT:= 0;
timer.addEventListener(TimerEvent.TIMER,incrementCounter);
timer.start();
功能incrementCounter(事件:TimerEvent){
算上++;
//
FCOUNT = INT(计数*计数/ 10000); //开始时慢......然后加速
//
VAR whole_value:INT = INT(FCOUNT / 100); //变化值
VAR十分之一:INT = INT(FCOUNT / 10)%10;
VAR百分之一:INT = INT(FCOUNT)%10;
mytext.text = whole_value +:+十分+百分之一;
}
零点占位符
// $ C $下加入零占位符
功能formatCount(I:INT):字符串{
VAR部分:INT = I%100;
VAR全:INT = I / 100;
返回(0000000+全).substr(-7,7)+。 +(级分小于100:)+馏分;
}
功能测试():无效{
对于(VAR我:INT = 1; I< 100000; I + = 3){
迹第(i + - >中+ formatCount(ⅰ));
}
}
获取未定义的属性的访问,myInt.toString();
//连接在一起
VAR定时器:定时器=新的定时器(10);
VAR计数:= 0; //为-1开始,如果你想小数点后第一位为0
VAR FCOUNT:= 0;
timer.addEventListener(TimerEvent.TIMER,incrementCounter);
timer.start();
myInt.toString();
功能incrementCounter(事件:TimerEvent){
算上++;
//
FCOUNT = INT(计数*计数/ 10000); //开始时慢......然后加速
//
VAR whole_value:INT = INT(FCOUNT / 100); //变化值
VAR十分之一:INT = INT(FCOUNT / 10)%10;
VAR百分之一:INT = INT(FCOUNT)%10;
mytext.text = whole_value +:+十分+百分之一;
}
功能formatCount(I:INT):字符串{
VAR部分:INT = I%100;
VAR全:INT = I / 100;
返回(0000000+全).substr(-7,7)+。 +(级分小于100:)+馏分;
}
功能测试():无效{
对于(VAR我:INT = 1; I< 100000; I + = 3){
迹第(i + - >中+ formatCount(ⅰ));
}
}
NO ERROR现在,把它弄坏了一些其他的方式
VAR定时器:定时器=新的定时器(10);
VAR计数:= 0; //为-1开始,如果你想小数点后第一位为0
VAR FCOUNT:= 0;
timer.addEventListener(TimerEvent.TIMER,incrementCounter);
timer.start();
功能incrementCounter(事件:TimerEvent){
算上++;
//
FCOUNT = INT(计数*计数/ 10000); //开始时慢......然后加速
//
VAR whole_value:INT = INT(FCOUNT / 100); //变化值
VAR十分之一:INT = INT(FCOUNT / 10)%10;
VAR百分之一:INT = INT(FCOUNT)%10;
//////////////
功能formatCount(I:INT):字符串{
VAR部分:INT = I%100;
VAR全:INT = I / 100;
返回(0000000+全).substr(-7,7)+。 +(级分小于100:)+馏分;
}
功能测试():无效{
对于(VAR我:INT = 1; I< 100000; I + = 3){
迹第(i + - >中+ formatCount(ⅰ));
}
}
//////////////
mytext.text = formatCount(whole_value +:+ +十分之百分之);
// mytext.text = whole_value +:+十分+百分之一;
}
实施
//字符串到数字
VAR myString中:字符串=5;
VAR为mynumber:数=号码(MyString的);
//数字串
VAR为mynumber:数= 5;
VAR myString中:字符串=字符串(为mynumber);
//字符串为int(整数)
VAR myString中:字符串=5;
VAR敏:INT = INT(MyString的);
解决方案
myInt.toString();
How do I convert an integer to a string value?This must be easy. "Ya guys in SO are da best at explaining." I'm still working on these dumb counters.
NEED TO JOIN THIS TOGETHER
//My counter project "sends to dynamic text field"
var timer:Timer = new Timer(10);
var count:int = 0; //start at -1 if you want the first decimal to be 0
var fcount:int = 0;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
function incrementCounter(event:TimerEvent) {
count++;
//
fcount=int(count*count/10000);//starts out slow... then speeds up
//
var whole_value:int = int(fcount / 100); //change value
var tenths:int = int(fcount / 10) % 10;
var hundredths:int = int(fcount) % 10;
mytext.text = whole_value + " : " + tenths + hundredths;
}
ZEROS PLACEHOLDER
//Code for adding "zero placeholders"
function formatCount(i:int):String {
var fraction:int = i % 100;
var whole:int = i / 100;
return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" : "") + fraction;
}
function test():void {
for (var i:int = 1; i<100000; i += 3) {
trace(i + " -> " + formatCount(i));
}
}
Getting access of undefined property, myInt.toString();
//joined together
var timer:Timer = new Timer(10);
var count:int = 0; //start at -1 if you want the first decimal to be 0
var fcount:int = 0;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
myInt.toString();
function incrementCounter(event:TimerEvent) {
count++;
//
fcount=int(count*count/10000);//starts out slow... then speeds up
//
var whole_value:int = int(fcount / 100); //change value
var tenths:int = int(fcount / 10) % 10;
var hundredths:int = int(fcount) % 10;
mytext.text = whole_value + " : " + tenths + hundredths;
}
function formatCount(i:int):String {
var fraction:int = i % 100;
var whole:int = i / 100;
return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" : "") + fraction;
}
function test():void {
for (var i:int = 1; i<100000; i += 3) {
trace(i + " -> " + formatCount(i));
}
}
NO ERROR NOW, BROKE IT SOME OTHER WAY
var timer:Timer = new Timer(10);
var count:int = 0; //start at -1 if you want the first decimal to be 0
var fcount:int = 0;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
function incrementCounter(event:TimerEvent) {
count++;
//
fcount=int(count*count/10000);//starts out slow... then speeds up
//
var whole_value:int = int(fcount / 100); //change value
var tenths:int = int(fcount / 10) % 10;
var hundredths:int = int(fcount) % 10;
//////////////
function formatCount(i:int):String {
var fraction:int = i % 100;
var whole:int = i / 100;
return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" : "") + fraction;
}
function test():void {
for (var i:int = 1; i<100000; i += 3) {
trace(i + " -> " + formatCount(i));
}
}
//////////////
mytext.text = formatCount(whole_value + " : " + tenths + hundredths);
// mytext.text = whole_value + " : " + tenths + hundredths;
}
EXAMPLES
// string to number
var myString:String = "5";
var myNumber:Number = Number(myString);
// number to string
var myNumber:Number= 5;
var myString:String= String(myNumber);
// string to int (integer)
var myString:String = "5";
var myInt:int = int(myString);
解决方案
myInt.toString();
这篇关于一个整数转换为字符串AS3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!