# \[Flash CS3\] Little big OOP problem?!

**URL:** <https://forum.kirupa.com/t/flash-cs3-little-big-oop-problem/238981>\
**Category:** flash\
**Created:** [September 17, 2007, 6:18pm UTC](https://forum.kirupa.com/t/flash-cs3-little-big-oop-problem/238981 "2007-09-17T18:18:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefe](https://avatars.discourse-cdn.com/v4/letter/s/a88e57/32.png) [@stefe](https://forum.kirupa.com/u/stefe)\
**Post date:** [September 17, 2007, 6:18pm UTC](https://forum.kirupa.com/t/flash-cs3-little-big-oop-problem/238981/1 "2007-09-17T18:18:30Z")

</div>

Hi all,

i have little problem with AS3. I hope somebody will help me.

I create main movieClip “mainMC”. In this movieClip i’ll create two movieClips “frame1MC” and “frame2MC” each at own frame (frame1MC at frame 1 and frame2MC at frame 2). Both frames have stop(); in actions layer.

Than in movieClip “frame2MC” (at frame 2) i’ll create textField with instance name Txt.

To mainMC clip in library i’ll link class mainMC.

> package {  
> import flash.events._;  
> import flash.display._;  
> import flash.text.\*;

public class mainMC extends MovieClip {  
private var count:Number = 0;

public function mainMC() {  
this.addEventListener(Event.ENTER\_FRAME, onEnterFrame);  
}

public function onEnterFrame(e:Event):void {  
count++;  
if (count == 100) {  
gotoNext(count);  
}  
}

public function gotoNext(count:Number):void {  
this.nextFrame();  
frame2MC.Txt.text = count;  
}  
}  
}

And whats the problem? After count reach 100 gotoNext function will go to nextFrame and wanna insert some text. But it’ll do some error

TypeError: Error #1009: Cannot access a property or method of a null object reference.  
at mainMC/gotoNext()  
at mainMC/onEnterFrame()

whats the problem? can somebody help? same problem would be if i want to insert button to frame2MC which link back to frame 1 etc.:jail:

thx
