I suppose your doors has some kind of numeric order. Just activate the door that corresponds with todays date. A simple way to retrieve this day would be
Code:
var todaysDate:Date = new Date();
var active_date = (Number(todaysDate.getDate()));
trace(active_date)
Thanks a lot for that. I'm a bit unsure how to use this code though? Do I put it on the timeline or instance? What parts of the code if any do I change?
don't change anything. I would the function, that opens the doors with the active_date as a parameter:
Code:
function open_door_function(active_date){
//this function opens door where door_number equals active_date
}
var todaysDate:Date = new Date();
var active_date = (Number(todaysDate.getDate()));
trace(active_date)
open_door_function(active_date);
Hmmm,
thanks again but I'm still a bit confused. I just put it on the timeline. I have a door which is an instance and named door1. It opens when I click on it.
well .. if you have 24 movieclips named door0, door1, door2, door3 etc, each with and opendoor-animation you would have to deactivate all doors except the door that corresponds with todays date. Perhaps something like this would do the trick for you:
Code:
var todaysDate:Date = new Date();
var active_date = (Number(todaysDate.getDate()));
// DISABLE ALL DOORS AND ENABLE ONLY THE DOOR
// THAT CORRESPONDS WITH TODAYS DATE
function disable_doors(){
// loop through all door-movieclips
for (var i:Number = 0; i < 24; i++){
_root["door" + i].enabled = false;
}
// reactivate todays-date-door
_root["door" + active_date].enabled = true;
}
Place this code in the timeline in the same frame as your door-movieclips. Does this give you an idea of where to go?
Hi hope I'm not annoying u with this but I just tried the code. I even tried to change it to door29 as I thought it might be referring to the number written in the instance name.
Just so u understand a bit more how its structured I have a movie named door and a stop action at the beginning and end of that. Its made into an instance named door with a btn over the top that says when clicked play movie. I only have one door so far but I'm looking to make more and name them like you said door1, door2 ect.
Thanks!!
Stefan
My boss just came over stressing at me. He's gonna make me stay if I don't get this done and I have no clue what to do to get it working!! Pllllllllllleeeeeease!!! Someone help!!!! Thanks!!!!!!!!!!!!!!!!!!
Thanks so much. I know I should have started earlier but I've had loads of work this week and haven't had the chance. So with this code I notice if you change the number at the top - var active_date:Number = 21; it opens that day. So do I have to change the code daily as this wont be ok with mr boss-man.
Thanks sooooooo much tho.
Last edited by stefancostain; 11-29-2007 at 11:29 AM.
Since todays date is the 29th, this date woul'nt works, since there is only 24 doors. Therefore I inserted a fake date. The final code should then look like this :
Code:
var todaysDate:Date = new Date();
var active_date = (Number(todaysDate.getDate()));
function init(){
date_door_mc._visible = false;
for (var i:Number = 0; i < 24; i++){
date_door_mc.duplicateMovieClip("door_" + i, _root.getNextHighestDepth());
if (i < 5){
_root["door_" + i]._x = (_root.date_door_mc._width + 5) * i + 10;
_root["door_" + i]._y = 10
}else if (i < 10){
_root["door_" + i]._x = (_root.date_door_mc._width + 5) * (i-5) + 10;
_root["door_" + i]._y = 100
}else if (i < 15){
_root["door_" + i]._x = (_root.date_door_mc._width + 5) * (i-10) + 10;
_root["door_" + i]._y = 200
}else if (i < 20){
_root["door_" + i]._x = (_root.date_door_mc._width + 5) * (i-15) + 10;
_root["door_" + i]._y = 300
}else if (i < 25){
_root["door_" + i]._x = (_root.date_door_mc._width + 5) * (i-20) + 10;
_root["door_" + i]._y = 400
}
_root["door_" + i].date_txt.text = i+1;
_root["door_" + i].onRelease = function(){
_root["door_" + (this._name.substr(5,2))].door_mc._visible = false;
this.enabled = false;
}
_root["door_" + i].enabled = false;
}
_root["door_" + (active_date-1)].enabled = true;
}
init();