Flash - redirect to page at end of movie-howto?

Discussion in 'Web Design and Development' started by sk3pt1c, Jun 27, 2008.

  1. sk3pt1c macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #1
    i have made a little intro movie to a website i'm creating for a client and i want it to redirect to the home page when it's done playing.
    what function should i use in actionscript 3?
    is it enterFrame ?
    any help wood be appreciated, thanks
     
  2. decksnap macrumors 68040

    decksnap

    Joined:
    Apr 11, 2003
    #2
    Unless I'm missing something, just put a getURL on the last frame.
     
  3. sk3pt1c thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #3
    turns out you're right, but in Action Script 3 it's more like

    var url:String = "home.html";
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, '_blank');
    } catch (e:Error) {
    trace("Error occurred!");
    }

    _blank though opens the target in a new window, and _self doesn't seem to work for some odd reason...
    any ideas?
     
  4. sk3pt1c thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #4
    another way to go about it would be to add a stop(); at the last frame of the flash movie and this to the html of the page:

    <META HTTP-EQUIV="refresh" CONTENT="25;URL=redirect.html">

    so you can redirect to the page you want after a certain time (here 25secs)

    which works fine, but i'd rather have it all in the swf file because depending on people's connection speeds the flash file would take some time to load so it's not really certain that they'd see all of the animation within the time specified...

    which leaves us with the same problem with ActionScript, how to open the new url in the same window :(

    anyone?
     
  5. sk3pt1c thread starter macrumors 6502a

    sk3pt1c

    Joined:
    Nov 29, 2005
    Location:
    a simulacrum
    #5
    right, turns out that:

    var url:String = "home.html";
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, "_self");
    } catch (e:Error) {
    trace("Error occurred!");
    }

    works just fine, it was just not working on my computer due to
    security restrictions of the flash player...
    now, i don't know if it will work for some people and not for others
    but i'm guessing that since i can see it properly on the web so should others,
    right?
     
  6. decksnap macrumors 68040

    decksnap

    Joined:
    Apr 11, 2003
    #6
    Wow- I guess I will never be using actionscript 3. I can't believe they would make it that convoluted to do a getURL. Also, actionscript 3 won't let you use code from 1 and 2? Sounds fishy.

    The security restriction is just because you are previewing locally. Dump it on a server and test it- it should be fine.
     
  7. cromwell64 macrumors regular

    Joined:
    Jun 30, 2008
    #7
    If you write actionscript I would suggest starting to use version 3. It might seem more convoluted at first, but in many cases it actually makes coding easier. For very simple things it means that you may have to write more lines of code and if that is the case using version 2 is fine. For more complex projects though it makes it easier to write more efficient and cleaner code. At least that has been my experience. I was hesitant to use it at first because it was a pain to learn the new syntax, but it is definitely worth it for me since I have been writing a lot of actionscript lately.

    The changes to version 3 make it compliant with the ECMA-262 standard which actionscript is based on. Also actionscript 3 code executes much faster than previous version because of the new virtual machine that runs it. The reason you can't use version 1 or 2 code is because the new virtual machine does not understand that code.
     
  8. decksnap macrumors 68040

    decksnap

    Joined:
    Apr 11, 2003
    #8
    Yeah, personally the value of re-learning this for the third time is just not there. I'm not sure how relevant flash really is anymore. The only things I still need it for are banner ads and video- neither of which use complex code.
     
  9. cromwell64 macrumors regular

    Joined:
    Jun 30, 2008
    #9
    I'm not sure flash is that relevant anymore either. Other than video/animations and audio, I have a hard time seeing a legitimate use for it, especially when you can achieve many of the same effects with javascript.
     

Share This Page