A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: unknown null object/method error

  1. #1
    Member
    Join Date
    May 2010
    Posts
    32

    unknown null object/method error

    Hi
    I'm having a problem with this code for selecting a character for a game. The scrolling left and right codes work but when it comes to accepting the highlighted character, I get this;

    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
     at KnockoutGame_fla::MainTimeline/selectArc()
    All I want is for it to take the label of the current frame in the movie clip (which I defined already) and set it to a string, selectedChar.
    This is my code;

    Code:
    this.stop();
    var selectedChar:String = "";
    var backMusic:SoundChannel;
    var target:MovieClip;
    var gameTimer:Timer = new Timer(1000,1);
    
    p1c.gotoAndStop("Adeiza");
    target = p1c;
    
    backMusic= (new BackMusic2()).play();
    available = new Array(2,3,4,5);
    
    sButton.addEventListener(MouseEvent.CLICK, selectArc);
    
    gameTimer.addEventListener(TimerEvent.TIMER, game);
    
    function game(evt:TimerEvent):void {
    nextFrame();
    }
    function selectArc(evt:MouseEvent):void {
    selectedChar=target.currentFrameLabel;
    gameTimer.start();
    }
    p1c is an instance of the movieClip containing the characters. I'd really appreciate any help or ideas. Thanks

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    What do you get when you trace selectedChar or gameTimer?
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    May 2010
    Posts
    32
    Oh wow cancerinform... You rule!! I traced them and got null for both, but my main problem was the gameTimer. What it was, I defined gameTimer and all methods in frame 1 of layer A, that extends to frame 4 without a new keyframe(dunno if I explained that well) and called them from frame 4 in layer B, which has 4 keyframes all through. What I had to do was define gameTimer's 'properties' again in frame 4. Thanks again for more words of wisdom!!
    Last edited by sodiumbadams; 08-08-2010 at 04:43 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center