FORUMS: list search recent posts

Flash CS3 Link Button to URL

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
pcitydesign
Flash CS3 Link Button to URL
on Jul 3, 2007 at 8:51:21 pm

Hi, Im kinda new to Action Script. I have a button that I need to link to a URL. For some reason CS3 handles action script for buttons a little differently than past versions. When I try to apply actions to the button I get the message "Current selection cannot have actions added to it." Can someone please help me out and post the necessary code/procedure I need to go about to do this? Thank you in advance!


Return to posts index

FireLine Studios
Re: Flash CS3 Link Button to URL
on Jul 3, 2007 at 9:41:58 pm

Pretty much, no, exactly what I was asking in the thread right before this one..

I wish us both luck on getting an answer before the Holiday becomes a reality.

Christopher Knell
FireLine Studios
Burbank, CA


Return to posts index

cowcowcowcowcow
Sher Ali
Re: Flash CS3 Link Button to URL
on Jul 3, 2007 at 10:10:51 pm

You have option to choose from:
- Flash File Actionscript 3.0
- Flash File Actionscript 2.0


So you can choose the actionscript 2.0 option and do as you have been doing in previous flash versions.

If due to any reason you have to choose actionscript 3.0 then you can do this:

- Make a new button on the first keyframe and name it my_button
- Select the keyframe not the button and open the actions panel (F9)
- Attach the following code and test

my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"));
}


Hope this is what both of you were looking for.


--------------------
Sher Ali


Return to posts index


FireLine Studios
Re: Flash CS3 Link Button to URL
on Jul 3, 2007 at 11:16:16 pm

home.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.mydomain.com"));
}

This worked great for the first button in layer 1 but when I tried to add the same code with a different instance name [that of my second button] on layer 2, first frame as you noted, It returned the following in the compiler errors.

1021: Duplicate function definition.

Christopher Knell
FireLine Studios
Burbank, CA


Return to posts index

Sher Ali
Re: Flash CS3 Link Button to URL
on Jul 4, 2007 at 12:01:43 pm

You have add the following line for each button not the whole code:

home.addEventListener(MouseEvent.CLICK,clickHandler);


and change the home with the other buttons name.


Return to posts index

Shawnette Wilmarth
Re: Flash CS3 Link Button to URL
on Sep 17, 2009 at 8:30:07 pm

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/index_fla::frame1()

i added your code and got this message...


Return to posts index


FireLine Studios
Re: Flash CS3 Link Button to URL
on Jul 3, 2007 at 11:28:01 pm

BTW: I have 12 buttons in all. I used a Button Component from the component library.
Each is on it's own layer.

Christopher Knell
FireLine Studios
Burbank, CA


Return to posts index

Camilo Hoyos
Re: Flash CS3 Link Button to URL
on Nov 21, 2007 at 6:55:58 pm

This code opens the url in another window, how could I set it up to open it in "self"?

my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"));
}


Return to posts index

Sher Ali
Re: Flash CS3 Link Button to URL
on Nov 21, 2007 at 8:02:43 pm

navigateToURL has another optional string type parameter for window which can have 4 possible values. In order to open in the same window use _self, like:

my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"),"_self");
}


Return to posts index


wil ragan
Re: Flash CS3 Link Button to URL
on Dec 11, 2007 at 1:31:05 am



wilragan:)


Return to posts index

Alan Healy
Re: Flash CS3 Link Button to URL
on Aug 28, 2008 at 1:16:10 pm

Hello. I have a site with 2 frames. In the top frame I have a Flash nav bar. I'm am trying to change the url in the bottom frame but have no luck.


my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"),"_self");
}

This code works fine if I want the whole page to change, but I just want the bottom frame to change each time....any help ?



Return to posts index

Pieter Helsen
Re: Flash CS3 Link Button to URL
on Aug 28, 2008 at 3:58:13 pm

my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"),"nameOfMyFrame");
}

Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index


Lucila Orengo
Re: Flash CS3 Link Button to URL
on Oct 23, 2009 at 6:59:49 pm

Great working code. I have been trying to get the page to load to _self . Tried a bunch of options but they are not working. Please, help!


Return to posts index

Luvert Gravy
Re: Flash CS3 Link Button to URL
on Mar 5, 2010 at 5:51:00 pm

Hi everyone! ...and sorry for bad english...
I'm new in town so please dont't be cruel if my problem is stupid for you :] .
Anyway, after doing like You wrote a get error mesage:

1087: Syntax error: extra characters found after end of program.

What i need to do now?


Return to posts index

Sarah Goldfarb
Re: Flash CS3 Link Button to URL
on Mar 19, 2010 at 6:43:48 pm

Hi - I am amble to get Actionscript 3 to work, but how can I link a URL to a button in Actionscript 2?

thanks!


Return to posts index

JohnCary
Re: Flash CS3 Link Button to URL
on Jul 12, 2007 at 4:21:39 am

So would the code look like this?

home.addEventListener(MouseEvent.CLICK,clickHandler);
my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"));
}


OR

what would it look like?


Return to posts index

Sher Ali
Re: Flash CS3 Link Button to URL
on Jul 12, 2007 at 10:21:36 am

Yes.


-------------------
Sher Ali


Return to posts index

JohnCary
Re: Flash CS3 Link Button to URL
on Jul 12, 2007 at 2:13:47 pm

see I've got multiple buttons on my page as well. I have created an actions layer but I'm not quite sure what to put in there. this code
home.addEventListener(MouseEvent.CLICK,clickHandler);
my_button.addEventListener(MouseEvent.CLICK,clickHandler);
function clickHandler(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.adobe.com"));
}
should go into the code area for the button or the action layer. as far as each button goes, do i put "my_button" into the properties box for every button and just change the http destination for each button? OR since I'm going to be using this page on a website should I just add the link for that button in dreamweaver CS3??


Return to posts index

JohnCary
Re: Flash CS3 Link Button to URL
on Jul 12, 2007 at 2:17:57 pm

i tried putting that code in for each button and putting in "my_button" in the properties panel but I now get this error: 1021: Duplicate function definition.


Return to posts index

cowcow
JohnCary
Re: Flash CS3 Link Button to URL
on Jul 17, 2007 at 4:58:59 am

any suggestions?


Return to posts index

Chrissy B
Re: Flash CS3 Link Button to URL
on Jul 26, 2007 at 10:19:01 am

Got it!!!

What you need to do is this :-

After giving each button a name. I have called my buttons Yahoo, Ebay, Google, and BBC.
What you also need to do is call each 'MouseEvent.CLICK' a different name. I have chosen 'clickHandler1', 'clickHandler2', etc.

This code works perfectly for me.

Yahoo.addEventListener(MouseEvent.CLICK,clickHandler1);
Ebay.addEventListener(MouseEvent.CLICK,clickHandler2);
Google.addEventListener(MouseEvent.CLICK,clickHandler3);
BBC.addEventListener(MouseEvent.CLICK,clickHandler4);
function clickHandler1(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.yahoo.co.uk"));
}
function clickHandler2(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.ebay.co.uk"));
}
function clickHandler3(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.google.co.uk"));
}
function clickHandler4(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.bbc.co.uk"));
}

What do you think???


Return to posts index

Chrissy B
Re: Flash CS3 Link Button to URL
on Jul 26, 2007 at 10:43:43 am

Got it!!!

What you need to do is this :-

After giving each button a name. I have called my buttons Yahoo, Ebay, Google, and BBC.
What you also need to do is call each 'MouseEvent.CLICK' a different name. I have chosen 'clickHandler1', 'clickHandler2', etc.

This code works perfectly for me.

Yahoo.addEventListener(MouseEvent.CLICK,clickHandler1);
Ebay.addEventListener(MouseEvent.CLICK,clickHandler2);
Google.addEventListener(MouseEvent.CLICK,clickHandler3);
BBC.addEventListener(MouseEvent.CLICK,clickHandler4);
function clickHandler1(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.yahoo.co.uk"));
}
function clickHandler2(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.ebay.co.uk"));
}
function clickHandler3(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.google.co.uk"));
}
function clickHandler4(event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.bbc.co.uk"));
}

What do you think???



Return to posts index

Lenard Dingemans
Re: Flash CS3 Link Button to URL
on Dec 23, 2007 at 4:38:26 pm

how do you make the link open in the same page as the movie was in


Return to posts index

Sarah Keil
Re: Flash CS3 Link Button to URL
on Jan 11, 2008 at 2:29:44 pm

here's my actionscript code:

blog.addEventListener(MouseEvent.CLICK,clickHandler1);
about.addEventListener(MouseEvent.CLICK,clickHandler2);
links.addEventListener(MouseEvent.CLICK,clickHandler3);
function clickHandler1(event:MouseEvent):void{
navigateToURL(new URLRequest("http://monkeytrick.org/folio/blog.html"),"_self");
}
function clickHandler2(event:MouseEvent):void{
navigateToURL(new URLRequest("http://monkeytrick.org/folio/about.html"),"_self");
}
function clickHandler3(event:MouseEvent):void{
navigateToURL(new URLRequest("http://monkeytrick.org/folio/links.html"),"_self");
}


it works fine when i test it in flash, but when i actually upload it, none of the buttons go anywhere..thoughts? thanks in advance.


Return to posts index

Jake Mobbs
Re: Flash CS3 Link Button to URL
on Jul 18, 2008 at 12:59:50 am

Hi, I also have the same problem... It all works fine in flash but when I upload it, none of the buttons work.. Any ideas???


Return to posts index

Moe Jeanson
Re: Flash CS3 Link Button to URL
on Aug 23, 2008 at 2:56:05 am

I appreciate the help with my site! I also had the same problem as the previous poster. I could use the buttons in the flash file but not when uploaded to the site. However, when I changed the site from an .html file to an .htm file it worked PERFECTLY!!

Hope that helps!


Return to posts index

Mikel Allen
Re: Flash CS3 Link Button to URL
on Feb 17, 2009 at 10:21:46 pm

Hey everyone!

(AS3)

Ok, I am having the same problem. I have actually created 3 invisible buttons. Each has its own button layer and action layer. For each action layer I have used

my_button1.addEventListener(MouseEvent.CLICK,clickHandler1);
function clickHandler1(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mywebisite.com"));
}

my_button2.addEventListener(MouseEvent.CLICK,clickHandler2);
function clickHandler2(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mywebisite.com"));
}

my_button3.addEventListener(MouseEvent.CLICK,clickHandler3);
function clickHandler3(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mywebisite.com"));
}

When I test the movie I see the hand icon so I know it's an invisible button, but when I click on it, it goes out of the flash play like it wants to go to a browser, but nothing happens. When I upload the files I can see the hand icon again, but nothing happens when I click on the link. I tried the .html to .htm trick, but that didn't work either.

Any suggestions?



Return to posts index

Mikel Allen
Re: Flash CS3 Link Button to URL
on Feb 18, 2009 at 6:05:20 pm

I have actually moved my code to one actions layer and placed as:

button1.addEventListener(MouseEvent.CLICK,clickHandler1);
button2.addEventListener(MouseEvent.CLICK,clickHandler2);
button3.addEventListener(MouseEvent.CLICK,clickHandler3);
function clickHandler1(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mywebsite.com"));
}
function clickHandler2(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mywebsite.com"));
}
function clickHandler3(event:MouseEvent):void{
navigateToURL(new URLRequest("http://mywebsite.com"));
}

Still nothing when I click on it. On the same page are text links that work just fine. One is an email link and the other is a link to a url. If I click on those, they work. Weird. Any other suggestions?




Return to posts index

William Eichman
Re: Flash CS3 Link Button to URL
on Mar 13, 2009 at 3:43:18 am

I'm having a problem with this. I"m making a navbar in flash and it works fine in flash, but when I put it in my site nothing happens when I click on the buttons. Could anyone tell me why this is? Thanks.



Return to posts index

Mikel Allen
Re: Flash CS3 Link Button to URL
on Mar 18, 2009 at 8:36:03 pm

Still trying to find any answer. Can I post my fla for anyone to look at?

Thanks!



Return to posts index

plachu plachu
Re: Flash CS3 Link Button to URL
on Nov 10, 2011 at 4:25:29 pm

F... this, i also have this problem.

Forgot about this solution when u use as 2.0.

in AS 2.0 just make button and click on it. Then go to actionscript panel and wrote:

on(release)
{
getURL("http://www.google.com");
}

Do this to every btn that u must link somewhere.

--

if u use as 3.0 then you can use this method that u try to make working.

sory for my funny eng.


Return to posts index

Tycoon's Felon Angel
Re: Flash CS3 Link Button to URL
on Aug 9, 2012 at 2:52:12 am

I'm having a couple of issues... I'm very, very new to flash & have got everything up and running. You can see the website at http://www.blockpartyrecordsatlanta.com

The problem I'm having is with my store tab. I CDs are to be clickable & bring you to where you can purchase the CDs but I'm having a conflict of code with my Contact tab.

The following is the actionscript from the Store tab:


stop();

btn1.gotoAndStop(1);
btn2.gotoAndStop(1);
btn3.gotoAndStop(1);
btn4.gotoAndStop(1);
btn5.gotoAndStop(2);
btn6.gotoAndStop(1);

store1.addEventListener(MouseEvent.CLICK, clickLink);
store2.addEventListener(MouseEvent.CLICK, clickLink);

store1.buttonMode = true;
store2.buttonMode = true;


function navigateURL(url:String):void {
var urlCont:URLRequest = new URLRequest(url);
navigateToURL(urlCont);
}

function clickLink(event:MouseEvent):void {
switch(event.target.name) {
case "store1":
navigateURL("http://www.reverbnation.com/store/view_item_album/artist_360255?item_id=42693");
break;

case "store2":
navigateURL("http://www.reverbnation.com/store/view_item_album/artist_360255?item_id=1576835");
break;

}
}

The following is the actionscript from the Contact tab:

import flash.net.URLRequest;

stop();

btn1.gotoAndStop(1);
btn2.gotoAndStop(1);
btn3.gotoAndStop(1);
btn4.gotoAndStop(1);
btn5.gotoAndStop(1);
btn6.gotoAndStop(2);

twitter.addEventListener(MouseEvent.CLICK, clickLink);
facebook.addEventListener(MouseEvent.CLICK, clickLink);
reverb.addEventListener(MouseEvent.CLICK, clickLink);
email.addEventListener(MouseEvent.CLICK, clickLink);

twitter.buttonMode = true;
facebook.buttonMode = true;
reverb.buttonMode = true;
email.buttonMode = true;

function navigateURL(url:String):void {
var urlCont:URLRequest = new URLRequest(url);
navigateToURL(urlCont);
}

function clickLink(event:MouseEvent):void {
switch(event.target.name) {
case "twitter":
navigateURL("https://www.twitter.com/DEMDBOIS");
break;

case "facebook":
navigateURL("https://www.facebook.com/BPRATL");
break;

case "reverb":
navigateURL("https://www.reverbnation.com/demdbois");
break;

case "email":
navigateURL("mailto:INFO@BLOCKPARTYRECORDSATLANTA.COM");
break;
}
}

The error I get is the following:

Scene 1, Layer 'actions', Frame 90, Line 22 1021: Duplicate function definition.

Scene 1, Layer 'actions', Frame 90, Line 27 1021: Duplicate function definition.


Any help is greatly appreciated! I've searched and searched and trial-errored it and nothing seems to work..


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]