PDA

View Full Version : Button links all open to same webpage


NoahVZ
01-18-2011, 12:37 AM
Hello & thanks for reading this.

I currently have a flash banner with three simple buttons. Each button is suppose to direct to a different page however the only page that any of them link to is the first web page in my action script. Any ideas?

stop ()

trekbtn.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere (evt) {
navigateToURL(new URLRequest("page#1"), "_self");

}

specbtn.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere1 (evt) {
navigateToURL(new URLRequest("page#2"), "_self");

}

giantbtn.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere2 (evt) {
navigateToURL(new URLRequest("page#3"), "_self");

}

Thanks!

automator
01-18-2011, 02:53 PM
If you look at all your addEventListener statements, they are all pointing to the goWhere function. goWhere1 and goWhere2 aren't registered to any event source.

sher75
01-20-2011, 04:05 AM
in other words you need to create another funtion similar to your first on but fill it in with the correct URLs.

xdeath
01-24-2011, 12:14 AM
no. what there saying is you need to have one eventListener event that eventlistener has the name of the function its going to in it. you have 3 functions and three listeners but you told them all to go to the first function.

what you had:

stop ()
trekbtn.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere (evt) {
navigateToURL(new URLRequest("page#1"), "_self");

}

specbtn.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere1 (evt) {
navigateToURL(new URLRequest("page#2"), "_self");

}

giantbtn.addEventListener(MouseEvent.CLICK, goWhere)
function goWhere2 (evt) {
navigateToURL(new URLRequest("page#3"), "_self");

}


what you should of had:

/* took out the space inbetween code.
no point having something that isn't needed
i also fixed the links in your event listener
which was your actual problem.

i also noticed your functions weren't being
linked properly you only wrote "evt" and forgot
to write the end bit. i also added semi collans :P
so all should be correct now. */

stop();

trekbtn.addEventListener(MouseEvent.CLICK, goWhere);
function goWhere(evt:MouseEvent) {
navigateToURL(new URLRequest("page#1"), "_self");
}

specbtn.addEventListener(MouseEvent.CLICK, goWhere1);
function goWhere1(evt:MouseEvent) {
navigateToURL(new URLRequest("page#2"), "_self");
}

giantbtn.addEventListener(MouseEvent.CLICK, goWhere2);
function goWhere2(evt:MouseEvent) {
navigateToURL(new URLRequest("page#3"), "_self");
}