I am making a page in which I have used some flash components as buttons, to which I want to link to another HTML page but don't know how to do it. Can someone help me?
2 Answers
You have to place a event listener on your button to listen click events.
yourButton_mc.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
function onClick(e:MouseEvent):void{
navigateToURL(new URLRequest("page.html"), "_self"); // change "_self" to "_blank" if want to it open in other tab or window. More info in the links I wrote below.
}
4 Comments
user1572160
It's so complicated, I knew a smaller one like getURl... something like this which I don't remember. Can you tell what's that?
Marcelo Assis
getURL was in AS2. It's not that complicated, you just have to call navigateToURL and pass a URLRequest as parameter. Please read those 2 links I wrote below the code if you want to have a good understanding on that. :)
Marcelo Assis
Yes. Just make sure you'll add the listener using the name of your button (as I called "yourButton_mc" in my code).
user1572160
I am thinking to make 6 buttons in a single .swf file. This script is not working there. Why don't you even give "getURL..." script? May that work...
In Flash, click the button you will be using and give it an instance name, (under the properties panel), and change the code accordingly.
// URLRequest variable(where to navigate)
var pageOnAnySiteURL:URLRequest = new URLRequest("www.example.com/useGoogle");
// Navigation function
function navigateFunc(event:MouseEvent):void {
navigateToURL(pageOnAnySiteURL, "_blank");
}
// Fire off that event when button is clicked in FLash
buttonInstanceName_mc.addEventListener(MouseEvent.CLICK, navigateFunc);