convert an integer to a string as3

前端 未结 5 787
死守一世寂寞
死守一世寂寞 2020-12-20 16:58

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.

5条回答
  •  失恋的感觉
    2020-12-20 17:51

    COUNTER "DYNAMIC TEXT" with zero values solution
    I'm posting on behalf of Ed, a human that helped me over the phone. It was a problem with the string arguments and the syntax in 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); 
    } 
    

提交回复
热议问题