Flash 将整数转换为字符串as3
如何将整数转换为字符串值? 这一定很容易。“你们在da最擅长解释。”我还在处理这些愚蠢的计数器 需要将此连接在一起Flash 将整数转换为字符串as3,flash,actionscript-3,string,integer,Flash,Actionscript 3,String,Integer,如何将整数转换为字符串值? 这一定很容易。“你们在da最擅长解释。”我还在处理这些愚蠢的计数器 需要将此连接在一起 //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.addEv
//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;
}
零占位符
//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));
}
}
myInt.toString() 我使用5+”
,无论何时添加”
(无字符),它都会将任何内容转换为字符串,并且易于记忆。使用零值解决方案计数器“动态文本”我是代表Ed发帖的,Ed是一个通过电话帮助我的人。mytext中的字符串参数和语法有问题
//CA, NC, LONDON, ED "increments"
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
mytext.text = formatCount(fcount);
}
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 : fraction);
}
//加利福尼亚州、北卡罗来纳州、伦敦,ED“增量”
var定时器:定时器=新定时器(10);
变量计数:int=0//如果希望第一个小数点为0,则从-1开始
var fcount:int=0;
timer.addEventListener(TimerEvent.timer,递增计数器);
timer.start();
函数递增计数器(事件:TimerEvent){
计数++;
fcount=int(count*count/10000);//开始时很慢,然后加速
mytext.text=格式计数(fcount);
}
函数formatCount(i:int):字符串{
var分数:int=i%100;
整个变量:int=i/100;
返回(“0000000”+整数)。substr(-7,7)+“+”(分数<10?“0”+分数:分数);
}
我觉得AS3有一个String()方法,可以显式地将数字类型的变量强制转换为字符串。整数可以很容易地转换成数字,我很确定在这种情况下它是隐式转换的
text = String(number);
文本=字符串(数字);
非常简单==>
var myint:int = 500;
var myintToString:String = myint+"";
如果我对你的问题理解正确,那么例子2似乎能回答这个问题。。。?您面临的问题是什么?将脚本添加到一起并播放。1120:访问未定义的属性myInt.toString();“我遗漏了什么?在你做toString()之前,myInt是在哪里定义的?我想是这样的。我的错误1120:访问未定义的属性myInt.toString();“看到我做的编辑了吗?”我想让你读一下这个错误,找出它的错误。(我不是想做一个蠢货,你只需要知道如何调试)如果你想不出来就告诉我,我会告诉你的。
//CA, NC, LONDON, ED "increments"
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
mytext.text = formatCount(fcount);
}
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 : fraction);
}
text = String(number);
var myint:int = 500;
var myintToString:String = myint+"";