Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

At work, we have a welcome screen w 2

Status
Not open for further replies.
Dec 24, 2001
857
GB
At work, we have a welcome screen which gives a bit of information about the place. On top of all this information, I've now been asked to add 'Days since last lost-time accident'. Obviously this is going to have to be updated everyday, and rather than do that, I was wondering how to do the following:

1) Use the SetVariable command to for example set 'Last' as a date.
2) Have a box which determines how many days ago 'Last' is e.g. Last = 01/01/02...date in box says '3 days since last accident'. The presentation will be continuous, so flash would have to update this box each day while it is running (sorta like refresh).

Thanks...
 
Would seem easier to me to set a starting date, 01/04/02 for example, in a date.txt file (that can be easily updated when there is an accident or whatever...), and then simply substract it from the current date, to display the total number of days without accidents.

Pseudo code...

Text file holding starting date.
Flash movie first reads that file to set the starting date, gets the current date, calculates the difference, and displays the number of days.
When there is an accident, you then simply uptade the date.txt file to reflect the new strating date.

Regards,
wink4.gif
ldnewbie
 
How would I go about doing that?

Do you know how I could do the following?

1) Set 'Last' = 01/01/02

2) Get a text box to get todays date and then work out how many days its been since 'Last' (01/01/02).

3) Get the text box to display the date it worked out in 2.

This is so that nobody has to update anything except the last lost-time accident.

I know how to do step 1, but not 2 & 3.
 
Well... Unless I'm misunderstanding you...
The "last" date would have to be updated at one point if there was an accident in 10 days, no? The 1/10/02 would then be the new starting date.
Are you suggesting, there'd be an input date box, and that the user would have to input the last starting date, before Flash calculated how many days it's been since?

Seems to me, it would be easier (to uptade anyways!) to read a text file holding the current starting date and have Flash calculate the number of days it's been from that starting date.
You could also set the current starting date in the html holding the movie, and pass it on to the movie. But the html would then need to be updated, like the text file, when an accident occured.

Might have a look at the calculating code over the weekend, if BBD is not already at it, and comes up with a suggestion!

Regards,
wink4.gif
ldnewbie
 
Its just going to be a flash movie in a stand alone projector, fullscreen with the menu bar hidden (so the only thing you can see is the movie). I don't mind having to go into the .fla file when (and hopefully not) an accident occurs and changing what the value of 'last' would be e.g. I wouldn't mind changing it from 01/01/02 to 10/01/02, and then just export the movie again.
This option of using a text file...how do I get flash to read the information from one? It would be useful if I could do that because I'd put the movie and text file in the same folder, and anytime an update is required, I'd just close down the movie, alter the text file and start the movie again.
If it takes a massive explanation and you can't be arsed writing it up, do you have any links to tutorials which might help me?

Thanks...
 
As I said, will have a look at it on the weekend...
Meanwhile, you could send me your e-mail at oldnewbie@hotmail.com, so that I might send you some test .flas.

Regards,
wink4.gif
ldnewbie
 
hi all


Loadvariables action in first frame to movie-clip containing text fields. All calcs held within the movie-clips onClipEvent (data) script. I've used the Date actions to get the date from the users computer rather than you having to define it in a text-file. Text file contains the date of the crash. Doesn't account for leap years but I'll leave that to you, should be easy for you.

Any questions to the email below, and I'll post any info in here as necesary.

Take it easy
dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
Thanks a lot...this is exactly what I need (well from the looks of it anyway). I hope you have no problem in me doing some copying and editing. If I have any problems, which I doubt I will, I'll mail you.

Again, thanks a lot...
 
So how about a vote for the man?

Hi Dave! ;-)

Regards,
wink4.gif
ldnewbie
 
hi Francois, hope you had a very festive xmas break!

All the best for 2002 mate.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
How do I edit the field where it says 'X days since last crash'?

Just double-click the movie-clip containing the text fields, then select the bottom text-field to edit the characteristics of the text-box. The text content of that box is defined.

As far as the content of that dynamic text box goes, it is defined in the line:

Code:
      newdays += " days since last crash";

.....at the very end of the calculation script.

dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
How about this:


If you want to do it in the Flash movie itself, and with much less coding (seems all Dave's from the other side like a lot of code!), this is the scripting:
Code:
stop ();

// Set starting date...
starting_date = new Date();
starting_date.setYear(2002);
// Months from 0 to 11
starting_date.setMonth(0);
starting_date.setDate(1);
// Convert starting date in milliseconds
starting_date_ms = starting_date.getTime();

// Get current date...
current_date = new Date();
// Convert current date in milliseconds
current_date_ms = current_date.getTime();

// One day in milliseconds...
one_day_ms = 1000 * 60 * 60 * 24;

//Calculate difference in milliseconds
difference_ms = Math.abs(current_date_ms - starting_date_ms);
    
// Dislay the number of days...
display = Math.round(difference_ms/one_day_ms)+" Days without crashes!";

Of course this could also work when reading a text file (as I first suggested!), and setting the starting date from te variables in that text file.

Regards,
wink4.gif
ldnewbie
 
or even simpler, on second glance X-):

loadVariables ("vars.txt", "_root.mc1");
crash = new Date(crashyear,crashmonth-1,crashday);
today = new Date();
diffMilliseconds = today-crash;
newdays = Math.floor(diffMilliseconds/86400000)+"Days Since Last Lost-Time Accident";


...with dynamic text box variable 'newdays' and text file (vars.txt) containing for example:

&crashday=1&
&crashmonth=1&
&crashyear=1999&


dave
dave@pinkzeppelin.com

^^^^^^^^^^^^^^^^^^^^^​
 
About five minutes after I mailed you, I found out how to do it. Anyway, its all looking ok. I'd mail you the .fla to see why I needed it, but its still 2mb when zipped.

I think I'll 'experiment' with this other option you've both given me, but for now I'll keep the one which is working because its gotta be ready for tomorrow.

Thanks for your help.
 
Dave,
Adding Math.abs even permits to calculate the difference without any specific order in the substraction. You could thus calculate days left, from today's date, before next Christmas, in the same manner without worring about substraction order errors.

diffMilliseconds = Math.abs(crash-today);
Or...
diffMilliseconds = Math.abs(today-crash);

Regards,
wink4.gif
ldnewbie
 
I found a little flaw... :-(
The actual date of our last lost time accident was 8th August 2001. When I put this info in, it tells me that theres been 153 days since the last accident, but it should say 151 (or was is 150...hmmm...one of the two). I'm pretty sure that it was 151 days.
It works fine if I tell it to use anything in 2002, but not 2001. I've had a quick check through a few things like the actionscript, but being a novice and all, it all looks Mongolian to me since I'm just beginning using code. One of the people I work with whose good with code and stuff is taking a look, but if you have any ideas...

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top