1

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 2

6

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.
}

Here are good resources on links and events.

Sign up to request clarification or add additional context in comments.

4 Comments

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?
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. :)
Yes. Just make sure you'll add the listener using the name of your button (as I called "yourButton_mc" in my code).
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...
2

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);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.