Hey all.
I had this code on frame 1 initally and it worked fine, however i’ve moved it along some frame so I could put an intro to my game and now I’m getting an error.
The code is:
char_mc.[COLOR=#000000]addEventListener[/COLOR][COLOR=#000000]([/COLOR]Event.[COLOR=#000000]ENTER_FRAME[/COLOR], moveChar[COLOR=#000000])[/COLOR];
[COLOR=#993300]function[/COLOR] moveChar[COLOR=#000000]([/COLOR]event:Event[COLOR=#000000])[/COLOR]:[COLOR=#993300]void[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]leftKeyDown||rightKeyDown[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"walk"[/COLOR][COLOR=#000000])[/COLOR];
enemySpawn[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]leftKeyDown[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#000000]scaleX[/COLOR]=-[COLOR=#000000]1[/COLOR];
char_mc.[COLOR=#000000]x[/COLOR]-=mainSpeed;
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]char_mc.[COLOR=#000000]x[/COLOR]<[COLOR=#000000]100[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#000000]x[/COLOR]=[COLOR=#000000]100[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]rightKeyDown[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#000000]scaleX[/COLOR]=[COLOR=#000000]1[/COLOR];
char_mc.[COLOR=#000000]x[/COLOR]+=mainSpeed;
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]char_mc.[COLOR=#000000]x[/COLOR]>[COLOR=#000000]650[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#000000]x[/COLOR]=[COLOR=#000000]650[/COLOR];
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]bg_mc.[COLOR=#000000]currentFrame[/COLOR]!=[COLOR=#000000]50[/COLOR][COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
bg_mc.[COLOR=#993300]nextFrame[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR] [COLOR=#993300]else[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]! charJumping&&! charPunching&&! charKicking[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"idle"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
bg_mc.[COLOR=#993300]stop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]upKeyDown||charJumping[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
charJump[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]charJumping[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"jump"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]aKeyDown||charPunching[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
charPunch[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]charPunching[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"punch"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]sKeyDown||charKicking[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
charKick[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#993300]if[/COLOR] [COLOR=#000000]([/COLOR]charKicking[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
char_mc.[COLOR=#993300]gotoAndStop[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]"kick"[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]
and the error I’m getting is:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at interactive_fla::MainTimeline/moveChar()
Any help would be fantastic.
Cheers.