MC´s aplha according to day time

how to determine the alpha of a movie clip according to the machine´s clock?

I tried your code but the alpha is not changing.
I´d like it gradualy to change it´s alpha from midnight = 0% and noon = 100%, and then after going down again.

Delondesign’s code looks good to me. You just need to make a few adustments here and there:

function setAlpha () {
var myNewDateObject = new Date();
var diff_hour = Math.abs (12 - myNewDateObject.getHours());
var alpha = Math.round(100/12*diff_hour);
yourClip._alpha = alpha ;
}

//Call the function every minute
setInterval (setAlpha, 60000);

pom :slight_smile:

I have the picture over a background.
This picture is a Movie Clip (named MC).
Changing the alpha of this movie clip would represent the corrent daytime.

when it´s night, the alpha would be 0% and when is daytime, it would be 100%.
Course it wouldn´t change from 0 to 100%, but gradualy according to the hours of the day.

i tried this code but didn´t work for me.
Don´t know what could doing wrong.

:red:

Sorry your head’s on fire. :puzzle:

My code was just a suggestion. This stuff is hard so I usually don’t get it right the first time. I’ll try to actually test it and post something that works but it won’t be until tonight or tomorrow. You keep trying.

To get the effect you’re looking for you’ll probably want to set up an array with all the values in it. This is assuming that having the alpha change once an hour is good enough. If you want it smoother than that you’ll have to use some different math.

alphaArray = new Array(0,8,16,25,33,41,50,58,66,75,83,91,100,91,83,75,66,58,50,41,33,25,16,8);
myNewDateObject = new Date();
hourVar = Date.getHours();
alphaVar = alphaArray[hourVar];
//This would pull the alpha number from the array you set up according to what hour it was.
targetMovieClip._alpha = alphaVar;

Again, this is just a suggestion. Make sure you’ve given the movie clip you’re trying to target an instance name and verify the target path. Tinker with it and I bet you can get it to work.

Good luck.

Changing once a hour is good enough.
I´l keep trying, thanks

Can you be more specific? Did it do anything? Did you try to trace the variables? I don’t have Flash here…

Oh yeah, and you need to replace ‘yourClip’ with the instance name of your clip, in that code I posted…

Alright, my code was a little off.

I did a little test fla and got it to work though so here it is.

Enjoy.

Thanks for your time delongdesign…
but it´s not changing the mc´s alpha. Both “Yes” Mc´s are alpha 100%.