PDA

View Full Version : adding variables to the Date function


you_rock
10-14-2002, 03:53 PM
I would like to add inputted hours to the system clock display.

I have created an input text field, but the variable is not added to the sum of the hours-- it is added sequentially after the hours.

So if you inputted 5.

The time would display

105:47

Instead of

15:47

Here is the timer from the tutorial I am using.

mydate = new Date();
time = mydate.getHours()+input +':'+mydate.getMinutes();

whereas *input* is the name of the text input variable

Thanks,
You rock!

you_rock
10-14-2002, 06:52 PM
I found the answer on Actionscript toolbox.

It reads:

"When a user types into an Input Text field (which is what a and b are), the data always comes into Flash as a string. So to do math operations on user-entered data, it must first be converted to a number with the Number function. Thus c = a * b++ is written in the movie as c = Number(a) * Number(b++);"

hope this helps someone else.