Flash 8 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript language elements > Global Functions > 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.
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:
_self specifies the current frame in the current window._blank specifies a new window._parent specifies the parent of the current frame._top specifies the top-level frame in the current window.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.
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");
loadVariables function, send (XML.send method), sendAndLoad (XML.sendAndLoad method)
Version 8
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
Comments
Desert Tiger said on Oct 23, 2005 at 3:29 PM : No screen name said on Nov 1, 2005 at 6:43 PM : cjones007 said on Jan 3, 2006 at 9:01 AM : cjones007 said on Jan 4, 2006 at 7:08 AM : Rui Camarinha said on Mar 10, 2006 at 8:23 AM : HansAZ said on Apr 5, 2006 at 11:14 AM : MeiaLua said on Apr 10, 2006 at 12:13 PM : drivingmenuts said on May 14, 2006 at 11:20 AM : No screen name said on Jun 20, 2006 at 5:45 PM : flasheister said on Aug 16, 2006 at 3:17 PM : No screen name said on Sep 25, 2006 at 12:37 PM : ROORvsB said on Oct 25, 2006 at 3:53 PM : No screen name said on Nov 4, 2006 at 7:46 AM : desertdiana said on Jan 15, 2007 at 6:05 PM : hopan said on Jan 24, 2007 at 12:27 AM : double_helixer said on Mar 5, 2007 at 12:47 PM : No screen name said on Mar 9, 2007 at 1:31 AM : No screen name said on Apr 19, 2007 at 12:46 PM : debarreraf said on May 2, 2007 at 10:07 AM : qtmouser said on May 9, 2007 at 1:03 PM : Roberto F. said on May 9, 2007 at 2:26 PM : No screen name said on May 10, 2007 at 8:06 AM : rainer.sven said on May 14, 2007 at 4:04 AM : kaptivate said on May 18, 2007 at 8:35 AM : No screen name said on May 22, 2007 at 12:34 PM : Raziel77 said on May 25, 2007 at 4:18 AM : anandaguy said on Jun 6, 2007 at 12:27 PM : anandaguy said on Jun 13, 2007 at 10:55 AM : sumesh.sivan said on Jun 29, 2007 at 5:51 AM : sumesh.sivan said on Jun 29, 2007 at 11:06 PM : No screen name said on Jul 18, 2007 at 6:54 PM : juankpro said on Aug 1, 2007 at 8:37 AM :