# Newbie question about frame switching

**URL:** <https://forum.kirupa.com/t/newbie-question-about-frame-switching/310624>\
**Category:** flash\
**Created:** [June 15, 2010, 9:42am UTC](https://forum.kirupa.com/t/newbie-question-about-frame-switching/310624 "2010-06-15T09:42:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![libellulo](https://avatars.discourse-cdn.com/v4/letter/l/f07891/32.png) [@libellulo](https://forum.kirupa.com/u/libellulo)\
**Post date:** [June 15, 2010, 9:42am UTC](https://forum.kirupa.com/t/newbie-question-about-frame-switching/310624/1 "2010-06-15T09:42:44Z")

</div>

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!
