Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Community Beginner ,
Jan 06, 2016 Jan 06, 2016

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

TOPICS
ActionScript
801
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 10, 2016 Jan 10, 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

...
Translate
Community Expert ,
Jan 07, 2016 Jan 07, 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 07, 2016 Jan 07, 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;

}

}

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 08, 2016 Jan 08, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 09, 2016 Jan 09, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 10, 2016 Jan 10, 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;

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 10, 2016 Jan 10, 2016

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2016 Jan 11, 2016

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 13, 2016 Jan 13, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 13, 2016 Jan 13, 2016

is the result what you want?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2016 Jan 14, 2016

Of coz not....

should be like this

5/6/2010

6/6/2010

7/6/2010

...

7/6/2015

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2016 Jan 14, 2016

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 14, 2016 Jan 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!!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 14, 2016 Jan 14, 2016
LATEST

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines