View comments | RSS feed

getURL function

getURL(url:String, [window:String, [method:String]]) : Void

Loads a document from a specific URL into a window or passes variables to another application at a defined URL. To test this function, make sure the file to be loaded is at the specified location. To use an absolute URL (for example, http://www.myserver.com), you need a network connection.

Availability: ActionScript 1.0; Flash Player 4 - The <code>GET</code> and <code>POST</code> options are available only in and later versions.

Parameters

url:String - The URL from which to obtain the document.

window:String [optional] - Specifies the window or HTML frame into which the document should load. You can enter the name of a specific window or select from the following reserved target names:

method:String [optional] - A GET or POST method for sending variables. If there are no variables, omit this parameter. The GET method appends the variables to the end of the URL, and is used for small numbers of variables. The POST method sends the variables in a separate HTTP header and is used for sending long strings of variables.

Example

This example loads an image into a movie clip. When the image is clicked, a new URL is loaded in a new browser window.

var listenerObject:Object = new Object();
listenerObject.onLoadInit = function(target_mc:MovieClip) {
 target_mc.onRelease = function() {
 getURL("http://www.macromedia.com/software/flash/flashpro/", "_blank");
 };
};
var logo:MovieClipLoader = new MovieClipLoader();
logo.addListener(listenerObject);
logo.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
 this.createEmptyMovieClip("macromedia_mc", this.getNextHighestDepth()));

In the following example, getURL() is used to send an e-mail message:

myBtn_btn.onRelease = function(){
 getURL("mailto:you@somedomain.com");
};

In the following ActionScript, JavaScript is used to open an alert window when the SWF file is embedded in a browser window (please note that when calling JavaScript with getURL(), the url parameter is limited to 508 characters):

myBtn_btn.onRelease = function(){
 getURL("javascript:alert('you clicked me')");
};

You can also use GET or POST for sending variables. The following example uses GET to append variables to a URL:

var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
myBtn_btn.onRelease = function() {
 getURL("http://www.macromedia.com", "_blank", "GET");
};

The following ActionScript uses POST to send variables in the HTTP header. Make sure you test your documents in a browser window, because otherwise your variables are sent using GET:

var firstName:String = "Gus";
var lastName:String = "Richardson";
var age:Number = 92;
getURL("http://www.macromedia.com", "_blank", "POST");

See also

loadVariables function, send (XML.send method), sendAndLoad (XML.sendAndLoad method)


Version 8

Comments


Desert Tiger said on Oct 23, 2005 at 3:29 PM :
how to i add subject and more that one body line to the email
eg:
on (release) {
getURL("mailto:me@shaw.ca;me@hotmail.com&?subject=Contest&body=Please enter me in the contest!Name:e-mail:phone number:"), "", "GET");
trace("Contest button pressed");

}
No screen name said on Nov 1, 2005 at 6:43 PM :
When I use the function getURL(url, window), I'd like to use the same window on the following getURL calls. I don't see you have any example on calling the window name. I tried to put in a window name, ie. getURL("http://google.com", "myWindowName"), but it brings up a _blank window. Please let me know. Thanks, Mai
cjones007 said on Jan 3, 2006 at 9:01 AM :
Hi

I'm trying to use a Flash movie to submit data to writable files. I'm having to do this via a PHP page - that's in a javascript popup (for aesthetic reasons):

on(release) {
getURL ("javascript:window.open('dateSubmit.php','popped','width=400,height=300,top='+((screen.height/2)-150)+',left='+((screen.width/2)-200)+',toolbar=no,scrollbars=no,resizable=no,menubar=no,status=no,directories=no,location=no'); void(0);", "POST");
}

but this just brings up a full blank (empty) window. What's going wrong? Can you use these variables when you're using javaScript in the URL parameter?

Thanks - appreciate all your help.
Chris
cjones007 said on Jan 4, 2006 at 7:08 AM :
Hi,

In the end, I just had to put two lines in the on(release):
getURL ("javascript:window.open('dateSubmit.php','popped','width=400,height=300,top='+((screen.height/2)-150)+',left='+((screen.width/2)-200)+',toolbar=no,scrollbars=no,resizable=no,menubar=no,status=no,directories=no,location=no'); void(0);");
getURL ("dateSubmit.php", "popped", "POST");

...and this works fine :D
Rui Camarinha said on Mar 10, 2006 at 8:23 AM :
hi,
I'm tryng to use getURL in a flash object to call a javascript function that resize an image in my html page

getURL( "javascript: resiseObj(objToResixe, newWidth, newHeight" );

with one flash object it works fine, but... if I do this in several flash objects simultaneously in the same page, i have a problem. The first image is resized, but the second movie never gets to execute the javascript function.

I think that my second GetURL doesn't happend because my first one is still runnig. Is this possible? if thats the problem how can I solve It.

Apreciate some help
HansAZ said on Apr 5, 2006 at 11:14 AM :
Error report:
We had a problem invoking a simple javaScript Alert() from Flash Player 8 to the HTML page. We created a simple test movieClip with one frame; the actionScript in the first frame was as follows:
getURL("javascript:alert()");

When the clip was published in Flash8 and tested in the HTML page... no alert box occurred. When the clip was published in Flash6 and tested in the HTML page... the alert box appeared.

Our solution was to publish a "java.swf" in Flash6 and in the first frame:
getURL("javascript:alert()");
and in the second frame:
stop();

Then, in the main movie in published Flash8, using:
loadMovie("java.swf", "_level2")

We loaded the swf published in Flash6 into the Flash8 player and our getURL() worked perfectly.
MeiaLua said on Apr 10, 2006 at 12:13 PM :
I got the subject and body text working like this:

contact_btn.onPress = function() {
getURL("mailto:name@place.com?Subject=Hey&Body=Your_site_is_incredible!");
}

Seems to work only if there's no spaces between the "", or at least that's all I could figure out.
drivingmenuts said on May 14, 2006 at 11:20 AM :
Replace the underscores in the prev. example with the plus sign. They will be interpreted as spaces when it hits the email client.
No screen name said on Jun 20, 2006 at 5:45 PM :
For Flash Lite 2, I believe you can also use getURL to make a phone call with the following syntax:

getURL("tel:"+phoneNum); // where phoneNum is the variable that store the phone number.

That should be included in the Flash Lite actionscript reference.
flasheister said on Aug 16, 2006 at 3:17 PM :
var myname:String = "numnuts";
getURL("http://localhost/test.cfm,"_blank","post");

...the posted variable is not available in the CFM file, i can use a loadvar to get it to work but why doesn't getURL work this way like the document says in help file. what gives?
No screen name said on Sep 25, 2006 at 12:37 PM :
getURL does not work to open a .doc file after XP2 is installed. it seems this is a common problem, but I can't find a solution. anyone have any idea.

i tried getURL with blank and java opennewwindow
ROORvsB said on Oct 25, 2006 at 3:53 PM :
Hi,

I have crated a short flash movie that at the end gives you 3 buttons. They all go to the same page which is were they need to be the only problem I have is I cant seem to get them to point to a specific part of the page. Each buttons relate to different info all on the same page. Can someone tell me to get them to open up on a specific are on the page.
No screen name said on Nov 4, 2006 at 7:46 AM :
myBtn_btn.onRelease = function(){
getURL("javascript:alert('you clicked me')");
};

This documentation is incorrect. Javascript calls does not work from swfs published for player 8 or higher.
desertdiana said on Jan 15, 2007 at 6:05 PM :
Hi,

New to action script so somthing simple is hard. Trying to submit a form and it does work, but the open window stays there. Is there a way to submit and not deal with this open window? My code is as follows:

on(release) = function() {
getURL("/cgi/gdform.cgi", "GET");
var name = "";
var company = "";
var email = "";
var questions = "";
}

Thanks for your help,
Diana
hopan said on Jan 24, 2007 at 12:27 AM :
the simple method getURL(mailto:anything@anywhere, target); which open the standard mail program does not work inside the disktop application ( windows exe ), sure it related with the internet browser , how to open the standard mail program when i have a disktop application ???
double_helixer said on Mar 5, 2007 at 12:47 PM :
While coding a site using HTML frames I found that a button launching:
getURL("somePage", "targetFrame")
...works perfectly when the .swf is published using the Flash Player 7 setting in Publish Settings, however publishing at Flash Player 8 causes the button to open the link in a new window/tab instead of the intended frame in both Firefox, Netscape, and Opera. Some features using LocalConnection() broke when published at FP8 also. The workaround obviously is to publish in 7, but that seems like a real bug to me, no?
No screen name said on Mar 9, 2007 at 1:31 AM :
Hi all.
Can any one help? I’m trying to use flash button to loud page to a frame in a frameset.
What I have tried is: in button action:
on (release) {
getURL(“page.html”,”frameName”)
} For what I can find, this is it. But noting happens in IE and FierFox opens a new page.
Help :,( code example would be cool
Thanks all.
No screen name said on Apr 19, 2007 at 12:46 PM :
this is the code I used to create a few buttons on my banner. one the background itself and one a small text item all converted into button symbol, background_btn, and click button. However I've sent a copy to my boss and when he opens it in ie7 the buttons are clickable but nothing happens when he clicks. did i code it wrong?

on (press, release) {
getURL("http://servedbyadbutler.com/redirect/;banID=519044648;CID=26366;setID=78118", "blank");
}
debarreraf said on May 2, 2007 at 10:07 AM :
Dear Friends, I used the first example, the above picture example, but I tried to open the page in the frame “mainWindow”, and in each test the program open a new window. How can I open a file in a frame?
Thanks in advance
qtmouser said on May 9, 2007 at 1:03 PM :
I can see by the comments above that I am in the same boat as other
people. I want to be able to load my page into a frameset without saving
down to a prior version. Has anyone found a good solution to this
problem?
Roberto F. said on May 9, 2007 at 2:26 PM :
Ow, I Think I got the same problem with the Frame Target
I would like to know how to solve this, to correct...

I'm using getURL("open.html", "frameName");
And nothin happens it well

So...

Help me!
No screen name said on May 10, 2007 at 8:06 AM :
To everyone who is trying to target a frame in Flash version 8:
Write the usual code in Flash...

on (release) {
getURL("services.html", "content");
}

But in the publish settings under the Flash Tab, check "Access network only" for the Local Playback Security at the bottom.

I think testing files remotely instead of locally also works as well.


And...if you are using code to fix active X or the like, be sure to change the code language at the top of your HTML back to something like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

instead of what flash writes which is:

<!-- saved from url=(0013)about:internet -->
<html lang="en">

Then it should actually work!
rainer.sven said on May 14, 2007 at 4:04 AM :
If Javascript calls do not work from swfs published for player 8 or higher,
see:
http://www.adobe.com/devnet/flash/articles/fplayer8_security.html
kaptivate said on May 18, 2007 at 8:35 AM :
Hi, I'm trying to load variables from an external text file into the getURL function. So, the external text file, say, "data.txt" would contain variables like:

var1=http://www.kaptivate.com/link1&var2=http://www.kaptivate.com/link2/

and the actionscript would be something like:

button1.onRelease = function(){
loadVariables("data.txt",button1);
getURL(var1);
};

but, 1: I don't want to have to load the variables for each different button, because there will be like 30 of them, and 2: I don't know how to have the getURL function recognize the proper variables. Any help? You can email me at mike@kaptivate.com. Much appreciated!

how would I get
No screen name said on May 22, 2007 at 12:34 PM :
With the Get URL function is it possible to set a fixed size for the window that you open? If so does it need to go in the get URL function?

Any help be greatly aprreciated

paul
Raziel77 said on May 25, 2007 at 4:18 AM :
I have a question if anybody can help.

My script works like this: getURL("javascript:show('images/0305.jpg')");

if i had a variable: var link:string = "images/0305.jpg";

how would I write the getURL replacing in the parenthesis the link with my variable???
anandaguy said on Jun 6, 2007 at 12:27 PM :
H-E-L-P PLEASE.

I have a botton in Flash 8 which controls a movie event, and I've used
the "Behaviors" function/window to specify "On Release" and/or "On
Press" to control the "Go to the webpage [URL]" http:www.xyz.com -- and
it works fine. BUT when I'm trying to get the "Behaviors" to use the
"mailto:Info@xyz.com" it only offers the option of opening it up in "_self"
in the "Behaviors" window.

So what happens is I get my "Mail" application to open and a new emai
is created addressed properly -- but I also (beneath that on the desktop)
get the webpage opening up to a blank page with no address (I assume
losing the original page that the visitor would have been clicking from
(I'm in Flash 8 testing the links in preview mode).

How can I get the botton which controls the movie (movie drops down a
different color in the link text box for the "Email") to ONLY open the email
application, and not mess with the browser window.

Your help is so so greatly appreciated! -- Thank you.

Tony
anandaguy said on Jun 13, 2007 at 10:55 AM :
I discovered (regarding the previous question involving an "Email" button
not opening up yet another browser window when opening up the viewer's
email application) that if I went into the button's Action window and deleted
the "_self" or "_blank", etc. reference in the HTML that it no longer
attempted to go to another browser window at the same time.

Thanks anyway y'all.
sumesh.sivan said on Jun 29, 2007 at 5:51 AM :
Hi, Im trying send email using mailto function. But my code is not working as expected. My code is:
on (release) {
getURL("mailto:" + to + "?subject=" +subject+ "&body=" + body);
}
My problem is that only TO address is getting filled on my Outlook Express. The Subject and Body parts are not working.

Your help is so so greatly appreciated! -- Thank you.

Sumesh
sumesh.sivan said on Jun 29, 2007 at 11:06 PM :
I used 'mailto' for this purpose and my code is as shown below,
on (release) {
getURL("mailto:some...@somewhere.com" + "?subject=Launching email "+
"&body=Not working well");


}


My problem is that only the TO address is getting filled up in the
email composition box. I need the Subject and Body to be get filled
up. Please help me...........
No screen name said on Jul 18, 2007 at 6:54 PM :
I did a Submit Form in Flash 8, and when I call the processForm.asp doesn't execute, somebody can help me with this, the asp and the swf are in the site alredy...
getURL("processForm.asp", "0", "POST");
Thank you.
juankpro said on Aug 1, 2007 at 8:37 AM :
The getURL target parameter refers to a frame name and not to a windowName so you cannot set an URL to open to the same pop up window
brsnyder117 said on Feb 11, 2008 at 11:16 AM :
There are two issues involving the use of getURL() calls introduced with the Adobe Flash Player 9 Update 3 (v9.0.115.0). Both of these issues are reproducible only in the Flash Player ActiveX control used by Internet Explorer for Windows. For more information, see http://kb.adobe.com/selfservice/viewContent.do?externalId=kb403072.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/8/main/00001730.html