gpt4 book ai didi

flash - 将整数转换为字符串as3

转载 作者:行者123 更新时间:2023-12-04 09:00:45 27 4
gpt4 key购买 nike

如何将整数转换为字符串值?
这一定很容易。 “SO中的你们最擅长于解释。”我还在做这些笨蛋柜台。

需要一起加入

//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));
}
}

获取未定义属性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));
}
}

现在没有错误,以其他方式破解
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;
}

示例
// 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();

关于flash - 将整数转换为字符串as3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2237940/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com