Web Design Forum: Actionscipt and Date - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Actionscipt and Date trouble with Date and if/if else statement Rate Topic: -----

#1 User is offline   Ravi 

  • Dedicated Member
  • PipPip
  • View gallery
  • Group: Members
  • Posts: 146
  • Joined: 16-August 07
  • Reputation: 0
  • Location:London
  • Experience:Intermediate
  • Area of Expertise:Coder

Posted 08 May 2011 - 12:02 PM

Hi,

Let me summarise what I want to happen. There are 3 scenes, 'general', 'may', 'june'. The .swf opens the general scene.
Open loading the .swf, the user will be led to a page with a button which they click. When the click the button 4 things can happen:

If the date is before 15 May, they will be taken to the same scene called 'general' and be told they have visited too early
If the date is May 15 - 31 (incl.) they will be taken to a scene called "May" and start on frame 1 if 15th, 2 if 16th and so on... (so frame number = [day] - 14)
If the date is June 1 - 24 (incl.) they will be taken to a scene called "June" and be placed on the frame number corresponding the day.
If the date is 25 June onwards, they will be kept in the same 'general' scene and taken to frame which tells them they are too late


I've got the following if statement setup on the button, but it won't work. Does anybody have any suggestions as to how I should alter my code to make it work? Or if anybody knows a script that will work, I would greatly appreciate it!

on(release){
    g = new Date();
    if( (g.getDay() < 15)   &&    (g.getMonth() <= 5)){gotoAndStop("general", 'early');}
    else if((g.getMonth() >= 6)     &&  (g.getDay() > 24)){gotoAndStop("general", 'late');}
    else if(g.getMonth() == 5){gotoAndStop("May", ((g.getDay())-14);}
    else if(g.getMonth() == 6){gotoAndStop("June", g.getDay());}
            }

This post has been edited by Ravi: 08 May 2011 - 01:00 PM

0

#2 User is offline   Ravi 

  • Dedicated Member
  • PipPip
  • View gallery
  • Group: Members
  • Posts: 146
  • Joined: 16-August 07
  • Reputation: 0
  • Location:London
  • Experience:Intermediate
  • Area of Expertise:Coder

Posted 08 May 2011 - 03:04 PM

Resolved.

Just had to use getDate() instead of getDay()

and getMonth() starts with Jan = 0, thus had to knock each month back a number. :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users