Hello all!
So what i’m trying to create is a landscape with an actual time-based day and night background(sun, moon).
This is what i have:
night_mc is a layer for the darkness of the night, set on multiply and the code controls the alpha-channel.
stage.root.addEventListener(Event.ENTER_FRAME, renew);
function renew(e:Event):void{
getTime();
}
function getTime():void{
var now:Date = new Date();
var sec:Number = now.getSeconds();
if (sec > 14 && sec < 44){
night_mc.gotoAndPlay("nightoff");
}else if(sec < 45 || sec > 15){
night_mc.gotoAndPlay("night_on");
}
}
I’m doing it with seconds so i wont have to wait 6 hours.
But the problem is that i want to have 4 stages of darkness.
- sunset (little bit dark)
- day (normal)
- dawn (little bit dark)
- night (dark)
But somehow that wont work.
Can somebody help me?