A Flash Developer Resource Site

Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 61

Thread: ADVENT CALENDAR - Doors not to be opened before date...

  1. #21
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    thanks again...

    Once again thank you!! One final question I wont bug u after this. How do I make it so the door animates open??

  2. #22
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    don't worry done it THANK YOU SOOOOOOOOOOOO MUCH!!!!!!!!!!!!!!!!!!

  3. #23
    Senior Member
    Join Date
    Oct 2002
    Location
    Copenhagen
    Posts
    228
    No problem

    The easy way would be to create a timeline-animation in the door_mc movieclip. Put a stop action in the first and the last frame of the timeline in the movieclip and change the button onRelease-function to this:

    Code:
    _root["door_" + i].onRelease = function(){
    	_root["door_" + (this._name.substr(5,2))].door_mc._visible = false;
    	this.enabled = false;
    	
    	// this code plays the doors_mc movieclip
    	this.play()
    }

  4. #24
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    ...

    Thanks SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO Much!!!!!!!!!!!!!!!!! It's pretty perfect now. Just want to ask a couple more quick questions. 1 - how would I jumble the numbers up? 2 - How do I make the numbers vanish when clicked on? Think that'll be it.

  5. #25
    Senior Member
    Join Date
    Oct 2002
    Location
    Copenhagen
    Posts
    228
    You're welcome :-)

    First:
    how would I jumble the numbers up
    What do you mean?

    Second:
    To remove the numbers after clicing the door, change the onRelease-function to this:

    Code:
    _root["door_" + i].onRelease = function(){
    	_root["door_" + (this._name.substr(5,2))].door_mc._visible = false;
    	_root["door_" + (this._name.substr(5,2))].date_txt.text = "";
    	this.enabled = false;
    	
    	// this code plays the doors_mc movieclip
    	this.play()
    }

  6. #26
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    excellent. With the jumbling numbers I mean they are all in order at the moment. How would I make the number be in a mixed order e.g. 12, 24, 5, 18, 1.....

  7. #27
    Senior Member
    Join Date
    Oct 2002
    Location
    Copenhagen
    Posts
    228
    That's not so straight forward as you might think. You Would have to use the Math.random method. The challenge lies in keeping track on which dates is already used/shown on stage, and then pick another random number and so on (hope you got that). A friendly advise, since you have a tight schedule, would properly be to put this feature in version 2 :-)

  8. #28
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    Ok maybe I'll have to leave that. Do you know how to move the doors about 100px to the right and also down?

  9. #29
    Senior Member
    Join Date
    Oct 2002
    Location
    Copenhagen
    Posts
    228
    These lines sets the X and Y coordinates for all the doors. Experiment with changing the numbers, you'll soon find that there's a system, just don't change the i-values :-)
    Code:
    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
    }

  10. #30
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    God sorry!!!! My boss isn't leaving me alone!!! Do you know how to open a html page when u click on a box? My boss has made a page for every day at 350x400 and wants that to load evertime a window is opened

  11. #31
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    not sure how secure you want it but someone just has to forward their user clock to open the doors...

    if u dont want this then u should retrieve the date from the server itself
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  12. #32
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    God sorry!!!! My boss isn't leaving me alone!!! Do you know how to open a html page when u click on a box? My boss has made a page for every day at 350x400 and wants that to load evertime a window is opened

    He wants this to open with day 1
    http://www.promo842.com/Advent/day01.htm


    http://www.promo842.com/Advent/day02.htm
    to open with day 2 ect.

    Pleeease help or I'm dead!!! last bit of help I need!!

  13. #33
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    ...

    God sorry!!!! My boss isn't leaving me alone!!! Do you know how to open a html page when u click on a box? My boss has made a page for every day at 350x400 and wants that to load evertime a window is opened

    He wants this to open with day 1
    http://www.promo842.com/Advent/day01.htm


    http://www.promo842.com/Advent/day02.htm
    to open with day 2 ect.

    Pleeease help or I'm dead!!! last bit of help I need!!

  14. #34
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    God sorry!!!! My boss isn't leaving me alone!!! Do you know how to open a html page when u click on a box? My boss has made a page for every day at 350x400 and wants that to load evertime a window is opened

    He wants this to open with day 1
    http://www.promo842.com/Advent/day01.htm


    http://www.promo842.com/Advent/day02.htm
    to open with day 2 ect.

    Pleeease help or I'm dead!!! last bit of help I need!!

  15. #35
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    ...

    God sorry!!!! My boss isn't leaving me alone!!! Do you know how to open a html page when u click on a box? My boss has made a page for every day at 350x400 and wants that to load evertime a window is opened

    He wants this to open with day 1
    http://www.promo842.com/Advent/day01.htm


    http://www.promo842.com/Advent/day02.htm
    to open with day 2 ect.

    Pleeease help or I'm dead!!! last bit of help I need!!

  16. #36
    Senior Member
    Join Date
    Oct 2002
    Location
    Copenhagen
    Posts
    228
    First of all: you should be aware of, as silentweed mentioned above, that there is no security in the solution I have shown you earlier. If you are workong on somekind of quiz, you most consider working on a server-solution instead. I asumed from your question, that security wasn't an issue, and therefor i suggested the solution as posted earlier.

    With this said, you should look at the code below. I've added a few lines that, when the doors are clicked, opens the page you posted earlier. A different page is open every day according to the system your boss have made:
    Code:
    _root["door_" + i].onRelease = function(){
    			
    	date_id = this._name.substr(5,2)
    	url_id = Number(date_id) + 1;
    	
    	if (url_id < 10){
    		url_id = "0" + url_id;
    	}else{
    		url_id = url_id;
    	}
    	
    	getURL("http://www.promo842.com/Advent/day" + url_id + ".htm", "_self")
    	
    	_root["door_" + date_id].door_mc._visible = false;
    	this.enabled = false;
    	
    }
    Again, this will make the final adventcalender-doors-code 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(){
    			
    	date_id = this._name.substr(5,2)
    	url_id = Number(date_id) + 1;
    	
    	if (url_id < 10){
    		url_id = "0" + url_id;
    	}else{
    		url_id = url_id;
    	}
    	
    	getURL("http://www.promo842.com/Advent/day" + url_id + ".htm", "_self")
    	
    	_root["door_" + date_id].door_mc._visible = false;
    	this.enabled = false;
    	
    }
    		
    		_root["door_" + i].enabled = false;
    		
    	}
    	
    	_root["door_" + (active_date-1)].enabled = true;
    	
    }
    
    
    init();

  17. #37
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    ...

    Thanks soooooooooooo much for this you really saved my skin!!!! Apparrantly the last guy who didn't manage to do this got sacked.
    Just wondered one last thing... promise its the last thing. If it's the 2nd can I make it so door 1 remains open or is still clickable. What I mean is after the date that is "todays date" is there a way of telling it to keep the doors before that date open or make them still clickable??
    Thanks again sooooooooooooooooooooooooooooooooooooooooooooooooo much!!!
    I'd probbably kiss ur feet if u were here. Even if they were smelly!! Lol.
    Thanks!!
    Stefan

  18. #38
    Senior Member
    Join Date
    Oct 2002
    Location
    Copenhagen
    Posts
    228
    Made a few changes to the code. I have added three boolean variables on top of the code. Set them to true /false, and the changes you asked for should show up. Commented the code, so it shouldn't be too hard to figure out. Attached the .fla and posted the code benieth.

    Have been quite bored today, so I guess you have been todays project. Glad to be able to help, seems like you could use it.

    Code:
    var open_pre_doors		:Boolean		= false; // toggle true/false, if previous doors should be open/closed
    var show_pre_dates		:Boolean		= true;	// toggle true/false, if previous dates should be visible/not visible	
    var disable_doors		:Boolean		= true;	// toggle true/false, if previous doors should be enabled/disabled
    
    // retrieve date from client-computer
    var todaysDate:Date = new Date();
    //var active_date = (Number(todaysDate.getDate()));
    var active_date:Number = 10;
    
    
    function init(){
    	date_door_mc._visible = false;
    	
    	// loops script 24 times
    	for (var i:Number = 0; i < 24; i++){
    		
    		// copy and plays all doors on stage
    		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
    		}
    		
    		// fills the textfields with dates
    		_root["door_" + i].date_txt.text = i+1;
    		
    		// sets all previous doors to opened
    		if (open_pre_doors == true){
    			if (i < active_date-1){
    				_root["door_" + i].door_mc._visible = false;
    			}
    		}
    		
    		if (show_pre_dates == false){
    			if (i < active_date-1){
    				_root["door_" + i].date_txt.text = "";
    			}
    		}
    		
    		// defines button actions
    		_root["door_" + i].onRelease = function(){
    			
    			// sets url-date-id
    			date_id = this._name.substr(5,2)
    			url_id = Number(date_id) + 1;
    			
    			if (url_id < 10){
    				url_id = "0" + url_id;
    			}else{
    				url_id = url_id;
    			}
    			
    			// empties textfield, disables door-click, opens door, sets http-url
    			this.date_txt.text = "";
    			_root["door_" + date_id].door_mc._visible = false;
    			this.enabled = false;
    			
    			getURL("http://www.promo842.com/Advent/day" + url_id + ".htm", "_self")
    			
    		}
    		
    		// disables doors
    		if (disable_doors == true){
    			_root["door_" + i].enabled = false;
    		}else{
    			if (i > active_date+1){
    				_root["door_" + i].enabled = false;
    			}
    		}
    	}
    	
    	// enables only todays door for clicking
    	_root["door_" + (active_date-1)].enabled = true;
    	
    }
    
    
    init();
    Last edited by lash; 03-11-2008 at 05:10 AM.

  19. #39
    Senior Member
    Join Date
    Oct 2006
    Posts
    114

    ...

    Hi,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    I know I promised the last question would be my last but I have 1 more definatly the last one this time...
    how do I make the pop-up window (html) resize to 350x400?
    I tried javascript but need to add in that bit of code that tells it plus-1 / +-1
    ... + url_id +
    I tried modifying the code below but can't get it working.
    PHP Code:
    getURL ("javascript:NewWindow=window.open('http://ntdesigns.net,'newWin','width=400,height=300,left= 200,top=200,toolbar=No,location=No,scrollbars=Yes, status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);"); 
    Last edited by stefancostain; 11-30-2007 at 07:01 AM.

  20. #40
    Senior Member
    Join Date
    Oct 2006
    Posts
    114
    Hi,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    Thank you!,
    I know I promised the last question would be my last but I have 1 more definatly the last one this time...
    how do I make the pop-up window (html) resize to 350x400?
    I tried javascript but need to add in that bit of code that tells it plus-1 / +-1
    ... + url_id +
    I tried modifying the code below but can't get it working.
    PHP Code:
    getURL ("javascript:NewWindow=window.open('http://ntdesigns.net,'newWin','width=400,height=300,left= 200,top=200,toolbar=No,location=No,scrollbars=Yes, status=No,resizable=Yes,fullscreen=No'); NewWindow.focus(); void(0);"); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center