![]() |
|
||||||||||
|
|||||
|
Регистрация: Jun 2007
Сообщений: 5
|
Добрый день!
Во Флеше не силен. Нашел вот такой счетчик - http://www.mjdigital.co.uk/blog/flas...ter-animation/ В принципе все устраивает, только есть вопрос: можно ли сделать чтобы данные писались не внутри кода, а брались из вне (например xml), то-есть там где сейчас 0555, менялось в зависимости от того, что написано во внешнем файле? Вот код: // Load Animation functions #include "mc_tween2.as" number = (_root.num!=undefined) ? _root.num.toString() : '0555'; function runCounter(o,myNum) { // SPEEDS - milliseconds: higher number = slower rollSpeed = 5; // speed of number rolls - default = 30 stopInterval = 1600; // time between stopping numbers - default = 300 initialPause = 3600; // pause before stopping numbers - default = 500 myNum = substring(myNum,0,4); // restrict to 7 characters // pad out number with zeros if less than 7 while (length(myNum)<4) { myNum = "0"+myNum; } len = length(myNum); for (i=0; i<=4; i++) { n = (i<parseInt(len)) ? myNum.charAt((parseInt(len) - 1) - parseInt(i)) : 0; if(o["d"+(i+1)]) { _root.runSequence(o["d"+(i+1)].digit,i,n); } setTimeout(_root.setNumer,(((parseInt(len) - 1) - parseInt(i))*_root.stopInterval)+_root.initialPause,o["d"+(i+1)].digit,n); } } function setNumer(o,n) { o.stop = true; clearInterval(o.timer); if(o.timer) { clearInterval(o.timer); } // backup in case the above fails o.timer = null; o.txt.text = n; o.yBlurTo(0,2); } function inc(o,n) { if(o.stop) { // backup stop command in case of failure clearInterval(o.timer); o.timer = null; o.txt.text = n; o.yBlurTo(0,2); } else { if(o.timer==undefined) { o.timer = setInterval(inc,_root.rollSpeed,o); o.yBlurTo(15,2); } o.txt.text = (parseInt(o.txt.text)<9) ? parseInt(o.txt.text)+1 : 0; } } function runSequence(o,delay) { o.stop = false; o.timer1 = setTimeout(inc,_root.rollSpeed+(delay*_root.rollSpeed),o,n); } runCounter(counter,number); Последний раз редактировалось Gaen; 16.04.2013 в 16:47. |
![]() |
Часовой пояс GMT +4, время: 21:54. |
|
|
« Предыдущая тема | Следующая тема » |
|
|