How to Link Flash Animation to a URL

January 8th, 2009 Jeremy Winter TechnologyWeb Development 20 Comments

I have seen this question many times, on many forums and blogs throughout the web and have at one time pondered the same question for my own projects. As far as I know, at this time, there is no way to wrap a flash animation with html code to make it a click able link, but if you have Adobe flash and a couple minutes you can complete the task.

This method is for files using Actionscript 2.0, not 3.0. Abobe changed the code in 3.0 to be about 5 times longer and 5 times more confusing. These steps will still work with 3.0 if you have the correct action script code for steps 11 and 12 though.

Steps to make Flash SWF Animation Clickable

  1. First, create a new .fla flash file in Adobe Flash(actionscript 2.0) or open your current file
  2. Create a new layer on the timeline above everything else (Insert>>Timeline>>Layer)
  3. Create a box on that frame with the Rectangle Tool (this will be the clickable area)
  4. Select the new layer(important!) then select the box
  5. Too the right under Color, Change the Stroke color and Fill color Alpha to 0%
  6. transparent box How to Link Flash Animation to a URL

  7. Double click the middle of the box
  8. Press F8 to convert the box to a symbol
  9. Name the box anything you would like
  10. Select the box again
  11. Next go to Window>>Actions or press F9
  12. Finally, copy this code in and replace page.html with your URL
  13. on(release){
    getURL("page.htm", "_self"); }

Now you can go to Control>>Test Movie and see that you new movie is now clickable. What we basically did was create a transparent button on top of our animation and made that a clickable link with the on(release) action script code.

If you have another way to accomplish this task or have the action script code for 3.0, leave a comment below with the details!

Technorati Tags: flash clickable link, flash click able link, flash tutorials, flash animation, flash adding link, flash with link, link url, click link, url link, flash video tutorial, flash html link, add link, flash insert link, flash link url, link to url flash, flash button link url, url link in flash, flash link geturl, link to url in flash, add url link to flash, geturl, get url, on release, release

Carl Jung’s Synchronicity
Best Gaming Laptop for the Money (Jan 09)

Comment with Facebook

20 Comments

  1. BadDesigns


    on (release) {
    getURL (“http://www.domainname.com/”, “_blank”);
    }

    this is the right script in a url-button


  2. I tried to do something similar to this using two separate buttons (one that covers the whole image and another that is entered on a “click here” button) that go to two different urls. Trouble is, whenever I load a page with the animation, both urls also open immediately without waiting to be clicked. I’m beating my head on a wall to figure out what I did wrong.

  3. Daniel


    Thanks a million! I’ve hunted like a Diogenes for a way to do this, and this is the only one that worked for me, and it’s also the simplest!!!


  4. Great! I am glad it worked easily for you Daniel. Adding a link is such a key thing we add to our flash videos, but for some reason their are not many tutorials on how to do it! Thanks for the comment Daniel and I hope to see you back around here again.

  5. Andrew


    Hi,

    I’m a beginner with Flash. I’m having troubles with creating a couple of buttons that link to different URLs. Everytime I add the actionscript in, the rest of the animations go funny (the stop actionscript on the other animations don’t work) and I get a syntax error. Any ideas?

    Please help…


  6. Andrew, if you’re getting a syntax error from simply adding the above code, my first guess would be that you are using actionscript 3.0. The OnRelease getURL code will only work with actionscript 2.0.

    If that isn’t the problem, you may want to try the creative cow forums http://forums.creativecow.net/. It is a great resource to look for help on problems like this one.

    Hope that helps a bit! Thanks for stopping by!

  7. Peter H


    Ditto to the above comments.

    Thanks SO much for supplying an easy yet hard-to-find answer to a very common question.

    Cheers, PH


  8. @Peter H – Glad to hear it was helpful!

  9. Edgar


    Thanks a million!!!

    Was scouring the net for an easy and comprehensible tutorial to do this seemingly simple task, and yours is the best! :D

    Thanks :D

  10. isobel McKenna


    Hi there,

    also new to as – I have followed your instruction to the tee (trying to link my flash file to a URL) but I keep getting 1087: Syntax error: extra characters found after end of program.


  11. @ isobel – Usually this error code happens when there is a missing opening or closing bracket like this {

    You might want to double check your code to see if a bracket is missing. Hope that helps!

  12. Rin


    Adobe Flash CS3 Professional doesn’t even let me copy and paste the clickable code on the button when I press F9 (Actions) and consider the code as an when I export the video:( Can anyone help?

    The errors are :
    1-Mouse events are permitted only for button instances
    on(release);
    …and I can’t even add the damn button in the Action options!!!

    2-Syntax Errors
    getURL(“http://light.cvgrenier.com/menu.html”, “_self”);


  13. Hi there i read the comments they were very useful but i am having a different problem i am trying to link my html file to a button and i entered this code in actions:
    on(release){
    getURL(“G:\E safety DIDA\E-portfolio\plan.html”,”_self”);
    }

    and when i click the button it says
    No web page was found for the web address: file:///G:/%20safety%20DIDA/-portfolio/lan.html

    so please help me please reply fast.
    thanks


  14. Great, it workst, been looking for something like this for ages.

    thanks a lot

  15. Huzair Kalia


    May u live long Buddy!!! thanks a bunch

  16. Chez


    Thanks so much for that link info, but as a Flash newbie I have one more question. When I go into F9 for actions… is the only link option a URL code? I’m building a new website and trying to link my flash animation to another page within my site, so when I use the URL code and test it, its trying to find an existing web page that right now doesnt exist other than on my computer. Hopefully this question makes sense to you! Actually I see someone else posted a similar issue, but I don’t see an answer from you, so I hope you can share your expertise with me as well!
    Thanks!

  17. chez


    I am trying to link my flash animation to another page within my site. I used your URL code in Actions, but when I test it since my URL doesnt exist (this particular web page has not been uploaded yet to the server) I obviously get an error message that the page doesnt exist. If I am simply trying to link to another page on my website, is there any other code besides that URL I can use in Flash Actions to link my animation?
    Thanks

  18. Joanna Larsen


    Hi-
    I am pulling my hair out trying to make my simple flash file link to a URL and nothing I have tried will work. I am following the directions as stated above but I can’t get it to work.
    I am making a transparent box on the top layer of my file, making it a movie clip or button and adding the code

    on (press){
    getURL(“http://www.trimergence.com/staging/news.html”);
    }

    or

    on (release){
    getURL(“http://www.trimergence.com/staging/news.html”);
    }

    The action says it has no errors, but when I export the move, my cursor turns to a hand but goes no where when I click. Any thoughts?


  19. Hi Joanna,
    My first guess would be that your flash file is using Actionscript 3.0 and not 2.0. The on(release) method only works in Actionscript 2.0.

    The page here does a good job of explaining the changes in 3.0. It’s a bit more complicated then a simple on(release), but isn’t drastically harder to implement.

  20. Zecaafonso


    Hey,

    I made a clip in Aftereffects, then I exported it to .xlf and made what you said on your post. But I get a 1086 syntax error expecting semicolon before leftbrace, and yes I wrote it using AC 1.0 & 2.0