archive: August 2009

26
AUG
2009

Time to give you another update on the flash header project for this time.

As you know for a while it’s been working where the time of day happens and updates every second. That’s one goal. The other was the sun/moon phases. That so far is unattainable at this point. I did however add another goal in the mix: Seasons.

After a bit of fuss while importing the different layers from Adobe Illustrator the different versions are imported. The only thing that seasons effect is the hill and what is on the hill.

  • Summer – Flowers, Grass, and Animated Butterfly.
  • Fall – Hill is a bit darker due to foliage and grass that is all “chewed” up.
  • Winter – Hill even bit darker on the top with a “cold” core and “snow caps” on each of the hills. (More on this later.)
  • Spring – The same you saw for the past 6 weeks.

For the animated butterfly to show up at random time, I setup a timer so that between 10 and 60 seconds it will go ahead and play.

// Date Holder
var dateCount:Object = new Date();

// Animation
var animation;
var randomTime;

// Static
var minrandomTime=10;
var maxrandomTime=60;

// Functions
if (minrandomTime>maxrandomTime) {
 trace("You can not have this.");
 stop();
}

function returnRandom() {
 trace("Running randomizer.");
 return (Math.floor(Math.random() * maxrandomTime));
}

function playAnimation() {
 trace("Running animation.");
 clearInterval(animation);
 play();
}

// The Code
if ( (dateCount.getHours() >= 7) && (dateCount.getHours() <=  20) ) {
 randomTime='';
 do {
 randomTime=returnRandom();
 trace("Random Time: " + randomTime);
 } while (randomTime < minrandomTime);

 trace("Butterfly has a GO for running.");
 animation = setInterval(playAnimation, (randomTime * 1000));
}

stop();

Simple enough? This sits inside the summer_mc movie clip that holds all the summer information. At one point I will have to create an “if” statement to keep the butterfly from moving in the rain.

At one point I might move all the animation to a single movie clip and have a whole bunch of switches to keep certain stuff from running depending on a whole bunch of factors.

Anyway… I think the next thing I will program in is the weather. Weather is going to be tied into my local weather. so if it raining it will rain, Snow… snow, etc.

Update: Most of this code is outdated minus the season code. More on this later!

Comments 1

Commenting is now closed