Monday, February 2, 2009

Doors of Perception




Head on over to Inadaville to check out a moving advent calendar solution.
Click here for the .fla file for the little door above.
Click here for the full moving doors .fla file o'er at Inadaville.
If you download the full moving doors, make sure you download this Door.as file and put it in the same location as the .fla file--otherwise the .fla file will not work.

Here's the code:
//Actionscript 2.0 doortestAS205.fla by Miles Inada

// Declare a boolean variable named shut, whose value (true or false) will indicate whether the door is currently shut (true) or open (false).
var shut:Boolean = true;

// Define the function openShutDoor. This function will check to see if the shut condition is true or false and act accordingly.
function openShutDoor() {
//check to see if the door is open or shut
if (shut) {
//if it's shut, open it
theDoor.gotoAndPlay(2);
//tell the program the door is now open
shut = false;
}else {
// if it's open, shut it
theDoor.gotoAndPlay(1);
//tell the program the door is now shut
shut = true;
} //end else
} // end function openShutDoor

// When theButton is clicked, run the openShutDoor function we've defined above
theButton.onRelease = openShutDoor;

// theDoor is a movie clip with a stop command on frame 1

3 comments:

Ben said...

No code on how they bounce around? I am saddened by ye little faith in our code interpreting skillz.

Miles Inada said...
This comment has been removed by the author.
Miles Inada said...

Lol--The code's up in the post now!
Git bizzy wit it!