Nov 21, 2009

Linking A Url To A Button - How to Link a URL using getURL()

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > Others

Linking A Url To A Button - How to Link a URL using getURL()

andrewsmithy
Linking a URL to a Button in Flash

This seems to be a problem for beginners to Flash, and I thought I'd address it. When building a Flash-navigated site, you need to link one page to another through the flash interface, just like you would a <a href="otherpage.html">my link</a> in HTML/XHTML.

Once you've created your button on the page, you can link the button very simply. Right-click it, and select "Actions" from the menu. This will open the ActionScript editor, in which you can right ActionScript code. Don't worry. It's not detailed to put this link in.
Make sure you are in Expert Mode, by clicking the arrow in the upper-right hand corner and selecting "Expert Mode". Now type the following code into the editor.

CODE

on (release) {
getURL("the_linked_page.htm","_self","GET");
}


The button you created will now go to that link when the mouse clicks it. The getURL function has a prototype that is like this:

getURL(url [,window [, method]])

The window and the method are optional parameters. The url define the resource you want to access. This could be an absolute address, such as "http://www.somesite.com/" or relative to the page that contains the flash movie such as "myotherpage.htm". The window parameter defines the window that you want the url to load in. This could be one of the following:
"_self" - Targets the window that the movie is in.
"_new" - Opens url in a new window
"_top" - Only useful in a framset, targets the top frameset
"_parent" - Targets parent window in a framset
"myWindowName" - where "MyWindowName" refers to the name of a frame in a frameset

The last parameter is one in which the method in which the url is requested, and is either "GET" or "POST". For most of your projects, you will normally use "GET". "POST" is for posting form data, but you usually use the loadVariables function to to this.

That wraps up the tutorial on adding a link to a button in a Flash Movie. I hope this helps everyone. If you have any questions or comments, please reply to this post.

 

 

 


Comment/Reply (w/o sign-up)

nickmealey
thanx, thats always nice to know. biggrin.gif

Comment/Reply (w/o sign-up)

hulunes
well,good post.this one must to be helpful to somebody who are new at making flash.using this kind of function at webpage ,could looks nice and professional.hope more and more grafics fans master this skill... biggrin.gif

Comment/Reply (w/o sign-up)

Trap FeedBacker
I am very new at using flash and i tried all that i know and more but whenever i open my button in ma web page n click it using the code that you just gave i keep getting this notice that my settings do not allow the button to interact with that particular site..plzz tell me how i should change the settings??

-Prashanth

Comment/Reply (w/o sign-up)

iGuest-Emmanuel Mtimba
The actionscript
Linking A Url To A Button

Thanks, the script was straight to the point

-reply by Emmanuel Mtimba

Comment/Reply (w/o sign-up)

(G)vestige
URL Link button at the end of a movie clip
Linking A Url To A Button

Hi all, I’m new to flash so hopefully someone can please help me out.. Using Flash CS4 with Actionscript 3.0 and it seems to me that many people are having issues with it?

I’ve created a movie clip and added a button on the last keyframe (so that the button doesn’t appear until the end).

I have added the following code to the last keyframe (when the button appears)

enterbutton.AddEventListener(MouseEvent.CLICK, onMouseClick);
Function onMouseClick(event:MouseEvent):void
{
Var request:URLRequest = new URLRequest (”http://www.Adobe.Com”);
NavigateToURL(new URLRequest(”http://www.Adobe.Com”), “_blank”);
}

Problem is, the little hand icon appears when I hover it over the button, but nothing happens when I click.. Been trying out all different codes but nothing works and I’m getting pretty frustrated now..

I’m sure there’s a Flash Guru who can help me out! =) Thanks in advance! 

-question by vestige

Comment/Reply (w/o sign-up)

(G)max
how can I get a working url button
Linking A Url To A Button

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

this is the complier error I was given after I imputted your code to my button as a test how can I fix this problem

-reply by max


Comment/Reply (w/o sign-up)

(G)andre
Why is it not linking
Linking A Url To A Button

Hi

I have a flash menu bar with fly out sub menus. The fly out sub menus should link to the other pages created in html. Obviously they are buttons embedded in movie clips at the moment. I tried the above ActionScript by applying it to the buttons, yet they do not link anywhere. The hand shows when you hover over them, yet nothing happens when you click on them, not even an error comes up. Please help? 

-question by andre

Comment/Reply (w/o sign-up)

(G)Trond
Linking in CS4 is a pain in the neck sometimes. Why not have the option to link in the Property Inspector as you can with text? Anyways, your problem might be the AllowScriptAccess parameter in the HTML document. It should be set to "always". It's got something to do with security. -reply by Trond

Comment/Reply (w/o sign-up)

barron1
QUOTE ((G)max @ Aug 7 2009, 01:43 PM) *
how can I get a working url button

Linking A Url To A Button



<p>1087: Syntax error: extra characters found after end of program.</p>
<p>this is the complier error I was given after I imputted your code to my button as a test how can I fix this problem </p>
<p>

-reply by max </p>


So how do I view the answer to this question?
MB

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


Searching Video's for linking, url, button, link, url, geturl
See Also,
advertisement


Linking A Url To A Button - How to Link a URL using getURL()

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com