Copy link to clipboard
Copied
e.g 5/7/2010 to 14/3/2016
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
...Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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;
}
}
}
}
Copy link to clipboard
Copied
1. are you using an old version of flash pro?
2. are you publishing for as2?
3. what exactly do you want your users to see?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
}
Copy link to clipboard
Copied
Ummm....it's not working...the date didn't count up, only a number count just next to the past_date
E.G. 6/5/2010 01...6/5/2010 02...
Maybe becoz of poor knowledge of actionscript
maybe i need to do 2000time for F6 to create keyframe and change the date by hand...
Copy link to clipboard
Copied
are you sure you're using as3?
do you have a textfield named tf to display the countdown?
did you make the obvious changes to the 3rd line:
var daysBetweenDates: Number = (current_date.time - past_date.time) / (1000 * 60 * 60 * 24);
and there's an typo in the text assignment. instead of
tf.text = 'Days since '+formatF(current_date)+' : '+count;
that should be
tf.text = 'Days since '+formatF(past_date)+' : '+count;
Copy link to clipboard
Copied
are you sure you're using as3? ----yes I am using as3
do you have a textfield named tf to display the countdown? -------yes i did
did you make the obvious changes to the 3rd line:
var daysBetweenDates: Number = (current_date.time - past_date.time) / (1000 * 60 * 60 * 24); ----sure, I did it
and there's an typo in the text assignment. instead of
tf.text = 'Days since '+formatF(current_date)+' : '+count; - Yes i corrected it
that should be
tf.text = 'Days since '+formatF(past_date)+' : '+count;
then the result:
Days since: 5/6/2010 01
Days since: 5/6/2010 02
...
Days since: 5/6/2010 10
Copy link to clipboard
Copied
is the result what you want?
Copy link to clipboard
Copied
Of coz not....
should be like this
5/6/2010
6/6/2010
7/6/2010
...
7/6/2015
Copy link to clipboard
Copied
then use,
var current_date: Date = new Date();
var next_date: Date = new Date(2010, 6, 5);
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 = formatF(next_date);
if (next_date.date==current_date.date&&next_date.month==current_date.month&&next_date.fullYear==current_date.fullYear) {
t.stop();
}
next_date=new Date(next_date.time+24*60*60*1000);
}
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;
}
Copy link to clipboard
Copied
thanks for your help
I think...I cant make it.
umm...many error and I cant find it..............
I give up, anyway thanks!!!
Copy link to clipboard
Copied
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?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now