Flash time-lapse headers
12 The main function
12 The main function
It looks complex but it isn’t! This is the function which will be controlling all the MCs which have 1 or 0 states, eg different graphics over two frames. In our case it will be the lights. To define the time period, we have to convert hours into minutes, eg 11am = 11*60minutes> 660. Therefore 11-12am is 660–720. Full step code is within the project files.
TimingDemo();
function TimingDemo() {
count++;
var lightPercent:Number;
var nightPercent:Number;
var dayPercent:Number=count/max;
// Sun rotation
if ( (count >= sunrise) && (count <= sunset) ) {
lightPercent = (count-sunrise) / (sunset-sunrise);
Sun.rotation = 325 + (70*lightPercent);
}
// Moon rotation
if ( (count >= moonrise) || (count <= moonset) ) {
mooncount++;
nightPercent = mooncount / (
(max-moonrise)+moonset );
Moon.rotation = 330 + (60*nightPercent);
} else {
13 Brighten it up/down
We want to be adjusting the brightness of all the elements over day/night. We will achieve that using the regular brightness attribute. We can also create darker/brighter for different elements (c,c2 etc), completely black for the ones far away and not so dark for the ones in the middle for example. Full step code is within the project files.
function SunRise(time) {
if ((time > 450) && (time < 630)) {
var percent = (time-450) / 180;
nightSky.alpha = 1-(1*percent);
var c:Color=new Color();
var c2:Color=new Color();
c.brightness = -0.8+(1*(percent*0.8));
c2.brightness=-1+percent;
hills.sign.transform.colorTransform=c2;
hills.transform.colorTransform=c;
grass.transform.colorTransform=c2;
bush.transform.colorTransform=c;
house.building.transform.colorTransform=c2;
bench.transform.colorTransform=c;
lamp.lampPost.transform.colorTransform=c;
houses.house.transform.colorTransform=c;
sale.saleTab.transform.colorTransform=c;
}
}
14 Once per minute switch
Finally, note that we tweaked the timing according to our liking, we can switch the updating of the scene to once per minute so that it lasts the whole day. The only thing we need to do is to change the ‘speed’ variable at the very top to 60,000 (1000s equals one second hence 60 seconds equals 60,000).
var speed:Number=60000


this is JUST what i’ve been looking for, thanks guys.
Fantastic! Great idea and well written walkthrough. I’m sure I’ll be using something like this in the near future. Thanks!
nice! and easy! definitely trying it!
Creative and easy, thanks for tutorial dude!
This is a fantastic idea, and on the right site would be different enough to make a real impact.
Thanks
Andy Phillips
I can’t get the files in the Zip to open properly. I get “Unexpected file format” when I try to open it.
Is that on my end?
live demo here:
http://www.strikermultimedia.com/blog/2009/11/time-lapse-flash-tutorial-in-web-designer-164/
:)
ooor, if your link doesn’t work, try this one:
http://www.blog.strikermultimedia.com/2009/11/time-lapse-flash-tutorial-in-web-designer-164/
:)
Very nice and useful tutorials for web designers,
Thanks for posting.