Newbie question about frame switching

Hi

I’m pretty new to Flash but basically I want to switch from frame 1 to frame 2 when the mouse rolls over an image and then to switch back when the mouse rolls out. However, I get the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at preweb_fla::MainTimeline/frame1()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::MovieClip/gotoAndPlay()
at preweb_fla::MainTimeline/mouseOutHandler1()

I’m using Flash CS4, Actionscript 3

The actionscript for the first keyframe is:
stop();

button1.addEventListener(MouseEvent.ROLL_OVER, mouseOverHandler1);

function mouseOverHandler1(event:MouseEvent): void{
gotoAndPlay(2);
}

And for the second:
stop();

button1.addEventListener(MouseEvent.ROLL_OUT, mouseOutHandler1);

function mouseOutHandler1(event:MouseEvent): void{
gotoAndPlay(1);
}

I would be extremely grateful for any help. It seems like something quite simply to do, but I can’t work it out.

Thanks!