Be a Supporter!

AS3 Listener help.

  • 342 Views
  • 4 Replies
New Topic Respond to this Topic
AntiAliasProductionz
AntiAliasProductionz
  • Member since: Apr. 20, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
AS3 Listener help. 2010-09-24 23:02:16 Reply

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
Response to AS3 Listener help. 2010-09-24 23:39:28 Reply

Flash forums are a graveyard, no?

ObeseDude
ObeseDude
  • Member since: Aug. 18, 2008
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to AS3 Listener help. 2010-09-25 00:23:10 Reply

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
Response to AS3 Listener help. 2010-09-25 08:19:44 Reply

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
Response to AS3 Listener help. 2010-09-25 17:02:45 Reply

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);}

BBS Signature