Regarding hyperlinks, there has been a significant change from Actionscript 2 to Actionscript 3.
In Actionscript 2, the following line of code would have sufficed to open a window in your default browser for this blog.
getURL("http://www.muktosoft.com/");
But in Actionscript 3, you need to instantiate an URLRequest then call navigateToURL to (:) navigate to your target url. See the code snippet bellow.
import flash.net.navigateToURL; var req:URLRequest = new URLRequest("http://www.muktosoft.com"); navigateToURL(req);
Code explained :
First of all, import the required class from flash.net pacakge.
Now instantiate a URLRequest object with the target url provided in constructor, for our example the target is muktosoft.com.
Then call the public function navigateToURL (provided in flash.net package) to, offcourse, navigate to that url.
You can also control whether the new page should load in the same window or in a different one by providing a second parameter. For example, to open the target page in a new window, you have to put “_blank” as the second parameter.
navigateToURL(new URLRequest("http://www.muktosoft.com"), "_blank");
The possible values for the second parameter and their meanings are
The second parameter actually lets you tell on which browser window or HTML frame to display the document indicated by the request parameter. You can enter the name of a specific window or use one of the following values:
* “_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.
Hope you find this useful.
6 Comments to “Hyperlink in actionscript 3”
Post comment
Search
News
Blog
- Fetching data from multiple tables in one MySQL query – Part 2
- Fetching data from multiple tables in one MySQL query
- Let’s Go A Hunting
- Java Applet and Javascript message passing
- The Right-Click Menu in Flash
- Stroke hinting
- Python: C++ style cin, cout in Python
- Python: Working in Unicode
- Website Security : Directory Listing Issue
- Hyperlink in actionscript 3


June 5, 2009 in

June 5, 2009 at 1:23 am
A most useful reference doc. Many thanks.
July 7, 2009 at 10:30 am
this class is nice
Steven Sacks made it http://www.stevensacks.net/2008/02/06/as3-geturl-solved/
example : Web.getURL(“http://www.google.com”, “_blank”);
July 7, 2009 at 5:51 pm
Thanks for mentioning.
I wanted to break some things down to details like the meaning of the second parameter.
September 29, 2009 at 1:16 pm
hmm. thanks
July 26, 2010 at 6:14 pm
[...] Read more from the original source: Hyperlink in actionscript 3 | Mukto Software [...]
July 26, 2010 at 7:02 pm
[...] Zobacz resztę artykułu: Hyperlink in actionscript 3 | Mukto Software [...]