Làm cách nào để chuyển đổi số nguyên thành giá trị chuỗi? Điều này phải dễ dàng. "Các bạn trong SO là những người giỏi nhất giải thích." Tôi vẫn đang làm việc trên những cái quầy câm này.chuyển đổi một số nguyên thành chuỗi as3
cần phải tham gia NÀY CÙNG
//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;
}
số không giữ chỗ
//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));
}
}
Tiếp cận tài sản không xác định, 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 VỚI DOANH NGHIỆP, bẻ ra một số cách khác
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;
}
VÍ DỤ
// 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);
nếu tôi hiểu Q của bạn một cách chính xác, ví dụ # 2 dường như để trả lời nó ...? bạn đang gặp phải vấn đề gì? –
Thêm tập lệnh cùng nhau và phát. 1120: Truy cập thuộc tính không xác định myInt.toString(); "Tôi đang thiếu cái gì? –
đâu là myInt được xác định trước khi bạn làm toString()? –