TwelvestoneFlash

silly n00b question, as2 getMonth


Sign in

  • Waiting for Godot ( 720 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 4.8 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.8 k posts )
    general front end design an...
  • Back End ( 9.6 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
arigato
 
2009-02-25

This seems to work fine but I'm getting a compiler error - what's wrong with it?

stop();

var myDate = new Date(); myMonth = myDate.getMonth();

if Number(myMonth) == 0 { gotoAndPlay(2); }

The error is '(' expected on the line starting "if Number".

DontBogartMe
 
2009-02-25

if (Number(myMonth) == 0) {

arigato
 
2009-02-25

Ah, sweet. Thanks!

I had to design a Flash banner that has a countdown clock with an event each month, but I need it to jump to the current month so it doesn't loop through all the previous ones on load.

lithium
 
2009-02-25

just remember that getMonth() is 0 based, i.e 0-11, not 1-12. That's burned me a few times k

Storm
 
2009-02-25

good tip lith

you could also:

var myMonth:Number = Number(myDate.getMonth());

so that you can freely refer to:

if(myMonth == 0)

without the extra confusing brackets. it's a little cleaner.

arigato
 
2009-02-26

I knew about the month starting at 0 thing but thanks for the tip. Trying to figure out my formatting I saw lots of people stumbling on that. k

ThanQ Storm but it's gone to ops for uploading once it passes the date shift tomorrow, it's out of my hands. If one date switch works they all will unless I got sloppy.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

silly n00b question, as2 getMonth