flash as3, Error #1009
        Posted  
        
            by smerels
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by smerels
        
        
        
        Published on 2010-06-16T19:41:47Z
        Indexed on 
            2010/06/17
            4:23 UTC
        
        
        Read the original article
        Hit count: 301
        
I'm making a website that exist out of linked pages. All the pages are on the time line and all the code is in an as3 file. The first page with links works but if I want to place a link on the second frame I get the 1009 error Cannot access a property or method of a null object reference. Because the link doesn't exist on the first frame. This is my code.
package { import flash.display.MovieClip; import flash.events.MouseEvent;
public class Honger extends MovieClip {
    public function Honger():void {
        weten.buttonMode = true;
        weten.addEventListener(MouseEvent.CLICK, onClickWeten);
        spelen.buttonMode = true;
        spelen.addEventListener(MouseEvent.CLICK, onClickSpelen);
        antwoorden.buttonMode = true;
        antwoorden.addEventListener(MouseEvent.CLICK, onClickAntwoorden);
    }
    public function onClickWeten(e:MouseEvent):void {
        this.gotoAndStop("vragen");
    }   
    public function onClickSpelen(e:MouseEvent):void{
        this.gotoAndStop("spel");
    }
    public function onClickAntwoorden(e:MouseEvent):void{
        this.gotoAndStop("sp");
    }
}
}
Does anyone know how to solve this problem within the code?
© Stack Overflow or respective owner