1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anyonw know how to redirect in flash?

Discussion in 'General Programming Chat' started by Moto801, Oct 2, 2010.

  1. Moto801

    Moto801 Senior Member

    Joined:
    Apr 25, 2009
    Messages:
    849
    Likes Received:
    413
    Location:
    Far away
    I know how to redirect to a url after a flash movie has finished. but what i want to do is set a date to when the redirect starts. like it doesn't start redirecting until a week has past.

    If anyone could offer any advice on how to do this it would be appreciated.

    Thanks
     
  2. RiskyShift

    RiskyShift Newbie

    Joined:
    Sep 16, 2010
    Messages:
    19
    Likes Received:
    3
    Something like this should work:

    Code:
    var now:Date = new Date();
    var trigger:Date = new Date(2010, 9, 2, 16, 15, 32); //2 October 2010 at 16:15:32
    
    if (now.getTime() >= trigger.getTime())
    {
        navigateToURL(new URLRequest("your url here"), "_blank");
    }
    
    The second date object is the date you want the redirect to trigger on. Note the second number in the Date() contructor is the month and is 9 instead of 10 as you might expect for October, that's because the months are 0-indexed, meaning January is 0. The date and time is UTC, not the local time of the computer the SWF is running on, so it should trigger at the same time all around the world.

    Edit: Obviously if you don't want to open in a new window use _self instead of _blank.
     
    • Thanks Thanks x 2
    Last edited: Oct 2, 2010
  3. RiskyShift

    RiskyShift Newbie

    Joined:
    Sep 16, 2010
    Messages:
    19
    Likes Received:
    3
    Oops, accidentally clicked quote instead of edit. :eek: