Skip to main content
Participant
March 2, 2011
Question

Making Main Images Links in Photo Gallery

  • March 2, 2011
  • 1 reply
  • 341 views

Hello.

I've made an image gallery and it works great. What I want to do is make the main image a link to a certain part of the site. The first link works great, but then I get: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Rockit_Front_Ad_fla::MainTimeline/frame1().

Basically, I made an invisible button on each main image for the link.

Can anyone help? Just want the links to work and can't get it. Any help is greatly appreciated. My AS3 is below:

Mike

stop();

Button1.addEventListener(MouseEvent.CLICK,showPic1);
Button2.addEventListener(MouseEvent.CLICK,showPic2);
Button3.addEventListener(MouseEvent.CLICK,showPic3);
Button4.addEventListener(MouseEvent.CLICK,showPic4);
Button5.addEventListener(MouseEvent.CLICK,showPic5);
Button6.addEventListener(MouseEvent.CLICK,showPic6);
Button7.addEventListener(MouseEvent.CLICK,showPic7);

IMG1.addEventListener(MouseEvent.CLICK,IMG1ClickHandler);
IMG2.addEventListener(MouseEvent.CLICK,IMG2ClickHandler);
IMG3.addEventListener(MouseEvent.CLICK,IMG3ClickHandler);
IMG4.addEventListener(MouseEvent.CLICK,IMG4ClickHandler);
IMG5.addEventListener(MouseEvent.CLICK,IMG5ClickHandler);
IMG6.addEventListener(MouseEvent.CLICK,IMG6ClickHandler);
IMG7.addEventListener(MouseEvent.CLICK,IMG7ClickHandler);

function showPic1(Event:MouseEvent):void{
gotoAndStop("Pic1");
}
function IMG1ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/products.asp?cat=31"));
}
function showPic2(Event:MouseEvent):void{
gotoAndStop("Pic2");
}
function IMG2ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/proddetail.asp?prod=BOOGIETA15"));
}

function showPic3(Event:MouseEvent):void{
gotoAndStop("Pic3");
}
function IMG3ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/products.asp?cat=61"));
}

function showPic4(Event:MouseEvent):void{
gotoAndStop("Pic4");
}
function IMG4ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/proddetail.asp?prod=MM25THANN"));
}

function showPic5(Event:MouseEvent):void{
gotoAndStop("Pic5");
}
function IMG5ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/products.asp?cat=14"));
}

function showPic6(Event:MouseEvent):void{
gotoAndStop("Pic6");
}
function IMG6ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/products.asp?cat=27"));
}

function showPic7(Event:MouseEvent):void{
gotoAndStop("Pic7");
}
function IMG7ClickHandler(Event:MouseEvent):void{
navigateToURL(new URLRequest("http://www.rockitmusic.com/products.asp?cat=49"));
}

This topic has been closed for replies.

1 reply

robdillon
Participating Frequently
March 3, 2011

That error usually means that some object doesn't exist in the frame where the Actionscript is located, or, that some object does not have an instance name. So, for instance, if your Actionscript is in frame 1, then Button1 through Button7 and IMG1 through IMG7 also need to be on frame 1.