Skip to main content
Participating Frequently
January 7, 2016
Answered

How can I create a count up calendar from designate period with actionscript 3.0???

  • January 7, 2016
  • 1 reply
  • 930 views

e.g 5/7/2010 to 14/3/2016

This topic has been closed for replies.
Correct answer kglad

Sorry for insufficient information

actually, i just wanna make a video and the count up period is part of the video.

just wanna show the date going from past to now (e.g 5/7/2010 to 14/3/2016), counting up the date let said 10 days/one second and finally it take around 1-2 mins to finish the count action.

I'm using adobe flash CC 2014, and the final product run in android.


so i assume you're not using an old version of flash and you're not using actionscript 2.

use:

var count:int = 0;

var current_date:Date=new Date();

var past_date:Date=new Date(2010,6,5);

var daysBetweenDates:Number=(date1.time-date2.time)/(1000*60*60*24);

var t:Timer=new Timer(100,0);

t.addEventListener(TimerEvent.TIMER,countdownF);

t.start();  // execute this line when you want to start the countdown display

function countdownF(e:TimerEvent):void{

tf.text = 'Days since '+formatF(current_date)+' : '+count;

count++;

if(count>daysBetweenDates){

t.stop();

}

}

function formatF(d:Date):String{

var mo:String = (d.month+1).toString();

while(mo.length<2){

mo='0'+mo;

}

var dateS:String = d.date.toString();

while(dateS.length<2){

dateS='0'+dateS;

}

return dateS+'/'+mo+'/'+d.fullYear;

}

1 reply

kglad
Community Expert
Community Expert
January 7, 2016

var date1=new Date(2016,2,14);

var date2=new Date(2010,6,5);

var daysBetweenDates:Number=(date1.time-date2.time)/(1000*60*60*24);

Participating Frequently
January 8, 2016

Then, should be like this???I'm totally not good at actionscript....the script is based on "http://html-tuts.com/count-up-timer-in-flash-actionscript-2/"

var date1=new Date(2016,2,14);

var date2=new Date(2010,6,5);

var daysBetweenDates:Number=(date1.time-date2.time)/(1000*60*60*24);

timerClip.onEnterFrame = function() {

if (this._currentframe == 30) {

second += 1;

// Day

if (Day> 30) {

Day= 0;

Day.text = "0" + second;

Month+= 1;

// Month

if (Month>= 10) {

Month.text = minute;

} else {

Month.text = "0" + Month;

}

// Year

if (Month> 12) {

Month= 0;

Month.text = "0" + Month;

Year+= 1;

}

} else {

if (Day>= 10) {

Day.text = Day;

} else {

Day.text = "0" + Day;

}

}

}

}

kglad
Community Expert
Community Expert
January 14, 2016

thanks for your help

I think...I cant make it.

umm...many error and I cant find it..............

I give up, anyway thanks!!!


create a new fla

add a textfield to the stage and assign it an instance name of tf

copy and paste that code into the actions panel

any problem?