dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Using the current date to load a swf

  1. #1
    Junior Member
    Join Date
    Sep 2002
    Posts
    19

    Using the current date to load a swf

    Hi all,

    I have a swf file that I use as the title for my website on my home page. I named the main file splash and I load it into _level1 of an otherwise empty file named splash_host. I have created several copies of splash and made each copy holiday oriented (easter bunnies easter, santas for christmas, etc..)

    My question is this: Can someone give me an example of the actionscript I would use to tell splash host a holiday is coming up and to load it's unique holiday file, not the original?

    Any help would be really appreciated.

    Thanks,

    Steve
    Steve

  2. #2
    You could try this:

    Code:
    function formatDate (theDate){
    	var months = ["January", "February", "March", "April", "May", "June",
    				  "July", "August", "September", "October", "November", "December"];
    	var dateString = months[theDate.getMonth()] + " "
    					 + theDate.getDate();
    	return dateString;
    }
    now = new Date();
    trace(formatDate(now));
    if(formatDate(now) == "December 25"){
    	loadMovie("christmas.swf", "splashHolder_mc");
    }
    else if(formatDate(now) == "February 14"){
    	loadMovie("easter.swf", "splashHolder_mc");
    }
    else {
    	loadMovie("regularSplash.swf", "splashHolder_mc");
    }
    Attached Files Attached Files
    Last edited by mpowelljr; 01-16-2005 at 07:44 PM.

  3. #3
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Nice code. Very similar to what I posted in this thread....

    http://www.flashkit.com/board/showth...hreadid=608059

  4. #4
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Great minds think alike!

  5. #5
    Cool, Glad to see that I am learning well then. I have been working my way through Colin Moock's "ActionScript for Flash MX" book. Alot of reading but well worth it.

  6. #6
    Banned NTD's Avatar
    Join Date
    Feb 2004
    Posts
    3,438
    Hi,

    Creating a function to handle things makes it more reusable than what I came up with, but similar in nature. Only so many ways to use the date object. Good idea.

    Regards
    NTD

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