Actionascript Timer Errors

Been working on a game called ChemoBlue for a while now and cannot seem to get rid of this error:

EDIT: I changed a few lines of code and the error is now this:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at ChemoBlueSetup/levelUp()[/Users/raphaelhennessy/Desktop/STS/Gold Cinema ChemoBlue/ChemoBlueSetup.as:71]

I used to have a lot more errors thrown at me but now this is the only one. Heres the code that creates the error. EDIT: I did some debugging and it seems the error comes from here:

public function levelUp(evt:MouseEvent):void
        {
            if (level == 1)
            {
                elementName.text = ("water");
                gotoAndPlay(1, "Level");
            }
                else if (level == 2)
            {
                elementName.text = ("sand");
                gotoAndPlay(1, "Level");
            }
            else if (level == 3)
            {
                elementName.text = ("???");
                gotoAndPlay(1, "Level");
            }
            }

Thanks in advance, -Raph

Upvotes: 0

Views: 54

Answers (2)

It seems I fixed it... in the function levelUp I removed the line making the dynamic text elementName say water if the level was one, which it wouldn't be anyway if that function was executed. Heres the code:

public function levelUp(evt:MouseEvent):void
        {
            if (level == 1)
            {
                gotoAndPlay(1, "Level");
            }
                else if (level == 2)
            {
                elementName.text = ("sand");
                gotoAndPlay(1, "Level");
            }
            else if (level == 3)
            {
                elementName.text = ("???");
                gotoAndPlay(1, "Level");
            }
        }

It throws no errors and acts just like I want it to. Thank you everybody!! -Raph

Upvotes: 0

User15937
User15937

Reputation: 13

Well I'm not sure if this will fix your problem, but your event listener currently has no parameters. All event listeners must have the event it listens for as a parameter.

So instead of

function frameUp2():void

it should say

function frameUp2(e:TimerEvent):void

Upvotes: 1

Related Questions