A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Error 1009. Should be an easy fix

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    4

    Error 1009. Should be an easy fix

    I just started learning ActionScript 3.0/Flash CS5 a day or two ago, and I am still very early on with it, however I do have some other web development experience with PHP and some Javascript.

    I am learning from a book that was written for Flash CS4, but it did not seem like a whole bunch was different. I am now getting "Error #1009: Cannot access a property or method of a null object reference. at Main()"

    I did several searches for the problem here, but most of the threads referencing this error are far more complex than what I am trying to do, involving multiple, long class files and the timeline. I have been unable to solve my problem after reading through various threads for hours now. Most of the fixes had to do with the timeline, however, all of my GUI is in one frame with no animation.

    Anyway, what I have is the beginning of a simple "Guess the number" game. I have a TLF text box for output text, a Classic text box for guessing input (not sure how to do input text boxes in Classic text since my book is for CS4), and a button to submit the guess. Here is my very short script I have so far:

    Code:
    package {
    	import flash.display.MovieClip;
    	import flash.events.MouseEvent;
    	
    	public class Main extends MovieClip {
    		var startMsg:String;
    		var mysteryNumber:uint;
    		
    		public function Main() {
    			outputBox.text = " ";
    			init();
    		}
    		
    		function init():void {
    			startMsg = "I am thinking of a number between 1 and 100.";
    			mysteryNumber = 50;
    			outputBox.text = startMsg;
    			input.text = " ";
    		}
    	}
    }
    I have commented out various code and determined that the problem is in both of the "outputBox.text" calls. The GUI will not show up until I comment both of them out. With them active, all I get are three blinking dots on the screen without the GUI loaded.

    As you can see, this script is quite trivial, and I have verified it is typed word-for-word from the book. I only have 3 GUI elements (all of which have instance names), and they are all on the same single frame in the timeline.

    If anyone can explain why I am getting this error, I would greatly appreciate it, because as it stands my learning of Flash and AS3 has slowed to a halt!

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    I would double check that all instance names are spelled/capitalized the same way as your code. The error message is basically telling you that you are referencing an object that does not exist. I find I often get this error when I've made a typo in naming items.

  3. #3
    Junior Member
    Join Date
    Feb 2011
    Posts
    1

    this *might* be the problem

    I ran into your thread while searching for a workaround for my own issue. I had been updating old .fla's (perfectly fine, functional .fla's) to new dimensions, and tried changing some of the text fields to TLF to work with some new features...

    Well TLF stopped those perfectly good files from working..
    Switching TLF back to classic text seems to fix the problem and make it all work again. I have stumbled across a few similar issues in my own search with this particular error stemming from TLF use... Unless you really need TLF I'd try sticking with classic text and see if that works for you.

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