AS3 Listener help.
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
I've got this set up so that on enter press it checks input in a text box and then checks to see if it matches anything. This was working totally fine yesterday. Today, I boot up flash, no changes to the file , and when i run it I get the 1009 error.(TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main())
What is this?
package
{
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.ui.*;
import flash.events.*;
public class main extends MovieClip
{
public function main()
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
input.text = "";
output.text = "enter play to start";
checkIf();
}
public function keyDownListener(event : KeyboardEvent)
{
if (event.keyCode == Keyboard.ENTER)
{
checkIf();
clearInput();
level1.gotoAndStop(nameMap[roomValue1][roomValue2]);
}
}
I've checked everything, the only problem is in the line of
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
i removed that and it didn't error out on me. Any help would be greatly appreciated.
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
- ObeseDude
-
ObeseDude
- Member since: Aug. 18, 2008
- Offline.
-
- Forum Stats
- Member
- Level 07
- Blank Slate
stage is null.
public function main():void {
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
//TODO - stage is no longer null
} farzher.com, it's not finished yet. Don't visit it!
- AntiAliasProductionz
-
AntiAliasProductionz
- Member since: Apr. 20, 2008
- Offline.
-
- Forum Stats
- Member
- Level 08
- Blank Slate
At 9/25/10 12:23 AM, ObeseDude wrote: stage is null.
public function main():void {
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void {
removeEventListener(Event.ADDED_TO_STAGE , init);
//TODO - stage is no longer null
}
I wish that were the problem.
The thing that boggles my mind is that that code worked yesterday, I haven't changed anything, and now it's erroring out on me.
- Redshift
-
Redshift
- Member since: Feb. 12, 2005
- Offline.
-
- Forum Stats
- Member
- Level 15
- Programmer
checkIf();
I don't see that defined in the class.
#include <stdio.h>
char*p="#include <stdio.h>%cchar*p=%c%s%c;%cmain() {printf(p,10,34,p,34,10);}";
main() {printf(p,10,34,p,34,10);}

