views:

248

answers:

2

I am new to Flash.

I am using Adobe Flash CS3 to create simple animations (images moving between keyframes). It produces a SWF file that I put on a website.

I want the SWF file to be a link to a URL. How do you do that?

Thank you in advanced!

A: 

1st you have to create an invisible button. An invisible button is a button with only the HIT frame. Create a button that covers all your stage. It will appear in your stage as a blue-transparent shape. Just click it and press F9 to bring the 'actions' window.

After that, just paste the following code into the window:

on(release){
    getUrl("here you put your url");
}

After that, just compile your code as AS2. I think that's the easiest way of doing this.

Bruno Schweller
That one is pretty slick.
Braveyard
Thanks Bruno. I didn't expect having to use AS. Do you know the code for AS3? Because all other projects here are using AS3.
I put it in another answer to paste the code properly.
Bruno Schweller
To confirm, this is AS2 code, not AS3.
Tyler Egeto
+2  A: 

The same answer using AS3: in the 1st frame that the invisible button appears, you should paste the following code:

myButton.addEventListener(MouseEvent.CLICK, linkToPage);
function linkToPage(e:MouseEvent):void{
    var request:URLRequest = new URLRequest("your page here");
    navigateToURL(request);
}

You should name the button instance 'myButton' (in the properties bar - the bottom-left input dialog). That should do the trick.

Bruno Schweller
to make the whole swf clickable, add the event to stage and not a button...
Joel Hooks
Perfect! Thank you Bruno and Joel