Viral videos from Unruly Media

Unruly Media creates viral campaigns for the world's top brands. The video is then distributed worldwide via Unruly Media's ad distribution network. See some of the videos here:

 








Linking to URL’s with movie clips or buttons

view all »


I came across an interesting question on a forum this week, which inspired me to write this short but useful tutorial on two ways to link URL’s to movie clips & buttons.

This is useful for linking from a flash file to an external site, the final result is this:

EXAMPLE

So, lets begin!

STEP 1

First, create a new actionscript 2 file. Rename the first layer to ’stuff’ and create a new layer called ‘actions’ then lock it.

STEP 2

Select the ’stuff’ layer. Create a movie clip on the stage. If you are unsure how to do this, please see the Beginners Guide to Flash - Part 2. Give this movie clip an instance name of MC_link1. Next, create another movie clip on the stage and give it an instance name of MC_link2.

STEP 3

Select the movie clip called MC_link1 first, press f9 to enter the actions layer, then apply the following code:
on(release){
getURL("http://www.the-dude.co.uk");
}

<–NOTE–> When linking to an external website, you MUST include ‘http://’ <–END NOTE–>

This basicaly means that when the user clicks then releases the mouse cursor on this clip ( ‘on(release){’ ) it will initiate the code to get the url. Press CTRL + Enter, then click your movie clip to see this in action.

But what if you want to keep all your code in one place on a seperate actions layer? Easy, with a few minor changes this can be done.

STEP 4

Now we are going to use the second movie clip we created, MC_link2. First, lock the ’stuff’ layer, select the actions layer and press f9 to enter the actions panel. Then enter the following code:
MC_link2.onRelease = function(){
getURL("http://www.the-dude.co.uk");
}

You will notice the function to call the URL is the same ( ‘getURL(”http://www.the-dude.co.uk”);’ ) but you need to tell flash which moviclip this relates to. This is what the first line does.

( ‘MC_link2.onRelease’ ) calls the movie clip MC_link2, and tells flash that when the user clicks then releases on said clip to run the function ( ‘= function(){’ ).

Hit CTRL + Enter and click the movie clips, you will notice there is no difference from the users point of view as they both link to the same place, but from our point of view inserting all of the actionscript on the same layer / frame will make it easier for you to go back and edit, as you know exactly where to find your script!

This works exactly the same with buttons, so go forth, have a play, expand on this and see what you can create! Feel free to leave a comment with a link to any creations you come up with from any of these tutorials.

Signing off,

The Dude

Questions? Ask them! Sign up now and email The Dude, or leave a comment below.

This tutorial will help you to have an attractive originally designed element on your website that you can make yourself even if you are a newbie without applying to professional web developers

Vote in HexoSearch Help me out by voting for this tutorial

Did this post help you? If so help us continue to grow and Digg this page or Share on Twitter!

If you haven't already, sign up to our RSS feed or register to recieve updates direct to your email!

5 Responses to “Linking to URL’s with movie clips or buttons”

  1. hendrikvandyk

    Hi

    I have various fly out sub menu buttons. When you mouse over the icon, four buttons fly out. The hand cursur appear when you mouse over the buttons, but when I put the script

    on(release){
    getURL(”http://www.the-dude.co.uk”);
    }

    in, still nothing happens. It does’nt link anywhere… not even a blank page? Please help!

    Thanks
    Andre

  2. mukteshwar

    Dear Andre you need to tye this code
    make a button
    on(release){

    getUrl(”http://yourwebsite”)

    }
    but you have still problem then open a new blank explorer and type in url which link you want to open and after open this you have to copy the url and paste on ; “yourwebsite” position.


  3. Some of the images were not displaying correctly but, the site still looks good. I have been coming to this blog for a couple of days now and i’m really impressed with the content. What is the rss address?


  4. Hello. Can anybody please help me with something… i can`t seam to get it thru… I want to set url`s to http://www.agnavag.ro/agnavag/ to the header’s 3 simbols from right. If anybody has an ideea please replay here :D


  5. Some of the images were not displaying correctly

Leave a Reply