Flash CS6 / Flex Error #1009: Cannot access a property or method of a null object reference

TypeError: Error #1009: Cannot access a property or method of a null object reference

ActionScript 3 Error #1009 is an AS3 that you can get for many anecdotal reasons. This error basically means that you are trying to reference something that isn’t there yet. That something can be a variable, data from the server, or even a movieClip or other display instance. So if you try and make a call to something and are getting this error simply look at what you are trying to reference and ask yourself is it there yet.
Don’t bang your head against the wall any longer. Here I explain one of the most un-obvious ways to get this error.

One reason that you will get AS3 Error #1009 is because you are trying to access a movieClip that isn’t instantiated yet. For example you try and reference a movieClip named loader_mc that is inside another movieClip. you are referencing it from a class that you created. Each time you run the test the movie you get the Run-Time Error #1009. You look inside your movieClip and see that the loader_mc is right where you want it. It is on frame 10 inside your animated moveiClip. That is when it dawns on you that the call to loader_mc happens when it is instantiated. Simply, put loader_mc on frame 1 and change it’s alpha to 0 and then the movieClip will be instantiated when the call from your custom class is made.

Another reason for this error is simply incorrect targeting. If you target parent.bob and the correct reference is parent.parent.bob then you will get this error as well.

Fix 1 :

Make sure the the reference is instantiated before it is called.  This means that the script is run after the object is loaded or the frame in the animation has been reached etc…

Fix 2 :

Check your targeting

Thanks and Happy Flashing

180 thoughts on “Flash CS6 / Flex Error #1009: Cannot access a property or method of a null object reference

  1. hi here is my code:

    btnBack.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_22);

    function fl_ClickToGoToScene_22(event:MouseEvent):void
    {
    removeEventListener(MouseEvent.CLICK, fl_ClickToGoToScene_22);
    MovieClip(this.root).gotoAndPlay(1, “Scene 2”);
    }

    and it says…

    [SWF] CamRollExCS5.swf – 315914 bytes after decompression
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at CamRollExCS5_fla::MainTimeline/frame1()[CamRollExCS5_fla.MainTimeline::frame1:4]
    at flash.display::MovieClip/gotoAndPlay()
    at CamRollExCS5_fla::MainTimeline/fl_ClickToGoToScene_22()[CamRollExCS5_fla.MainTimeline::frame4:97]
    Test Movie terminated.

    it still runs., but when i use the back button to go back to frame 2, all the other button is unclickable. and one button is gone xC pls help us out, it is for our research study and it is 2 weeks from now..

  2. You saved my project ..I’m making a flash app and I was getting that 1009 error because when loaded my button wasn’t found because it was in the 2nd frame so I copied and pasted that button on frame 1 and changed the alpha to 0 ..goshhh..thanks so much.. and your post saved me from going crazy ..:) and saved my project grade. thanks again !!

  3. You saved my project ..I’m making a flash app and I was getting that 1009 error because when loaded my button wasn’t found because it was in the 2nd frame so I copyed and pasted that button on frame 1 and changed the alpha to 0 ..goshhh..thanks so much.. and your post saved me from going crazy ..:) thanks again !!

  4. TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at FinalProject/hitTest()

    Code:

    package
    {
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.utils.Timer;
    import flash.ui.Keyboard;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.text.TextField;

    public class FinalProject extends MovieClip
    {
    //var goes here
    var sn:snake;
    var keys:Array = [];
    var bd:body;
    var bds:Array = new Array();
    var mo:mouse;
    var moARR:Array = new Array();
    var moSpawnChance:Number = 4;
    var moTimer:Timer = new Timer(3000);
    var partsArr:Array= new Array();

    public function FinalProject()
    {
    // constructor code

    }
    public function startGame()
    {
    //add snake and mouse at start of game
    addSnake();
    addMouse();

    //add mouse timer
    /*moTimer.addEventListener(TimerEvent.TIMER, addMouse);
    moTimer.start();*/

    }
    public function addSnake()
    {
    //call new snake
    //key listeners
    sn= new snake();
    addChild(sn);
    sn.addEventListener(Event.ENTER_FRAME, update);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
    stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
    addEventListener(Event.ENTER_FRAME, hitTest);

    }
    public function addBody()
    {
    bd= new body();
    addChild(bd);
    }
    public function addMouse()
    {
    var mo:mouse = new mouse();

    moARR.push(mo);

    addChild(mo);
    trace(“mouse spawn”);
    }

    function update(e:Event):void
    {
    if (keys[Keyboard.RIGHT])
    {
    sn.x += 5;
    sn.rotation = 180;
    }

    if (keys[Keyboard.LEFT])
    {
    sn.x -= 5;
    sn.rotation = 0;
    }
    if (keys[Keyboard.UP])
    {
    sn.y -= 5;
    sn.rotation = 90;
    }
    if (keys[Keyboard.DOWN])
    {
    sn.y += 5;
    sn.rotation = 270;
    }
    if (sn.x = 470)
    {
    sn.rotation = 0;
    sn.x = 460;
    }
    if (sn.y = 305)
    {
    sn.rotation = 90;
    sn.y = 300;
    }

    }
    function onKeyDown(e:KeyboardEvent):void
    {
    keys[e.keyCode] = true;
    }

    function onKeyUp(e:KeyboardEvent):void
    {
    keys[e.keyCode] = false;
    }
    //Add new part to the snake’s body

    function attachNewPart():void
    {
    var newPart:bodyPart = new bodyPart();

    addChild(newPart);

    partsArr.push(newPart); //add new part into snake body

    }
    function hitTest(evt:Event)
    {
    if ( mo.hitTestPoint(sn.x, sn.y, true))
    {
    trace(“hit”);
    }
    }

    }

    }

  5. Hi, What about this error displaying when accessing an empty table from a local sql database?

    var selectStmt:SQLStatement = new SQLStatement;
    selectStmt.sqlConnection = conn;

    selectStmt.text = “SELECT * FROM Guest ORDER BY entryID DESC”;
    selectStmt.execute();

    var result:SQLResult = selectStmt.getResult();

    The Guest table in this case is empty though no rows returned. If the table has more than one row, then the error doesn’t show up. Any other ways to check a database table if it’s empty or not without getting an error?

    thank you

  6. Curtis, you have no idea how many times you’ve helped me out. Once again, thank you!! 🙂

  7. Hi Curtis,
    Im actually having the 1009 error, but im tring to call a gallery that is working whit xml, Does the xml has any relation whit the 1009 error? i can paste the code if u can help me.
    Thank you

  8. dude.. u really save me… i was getting that error for like an hour.. didnt know what to do.. but at the end..i notice that i did a reference to a button that hasnt been loaded… i really never comment on anything.. but this time..
    i wanna say thx.

    🙂

  9. I have this code at login:
    stop();
    user1Btn.addEventListener(MouseEvent.CLICK, user1click);
    function user1click(evt:MouseEvent) {
    gotoAndStop(“desktop”);
    }
    and at desktop:
    logoff.addEventListener(MouseEvent.CLICK, logoffclick);
    function logoffclick(evt:MouseEvent) {
    gotoAndStop(“login”);
    }
    and i m getting the error 1009. Plz help.

  10. Hi Curtis,

    Your error explanations are actually made for humans to understand. I can’t thank you enough. I just read your post about the underlying reason why I’m running into error #1009, “Trying to reference something that isn’t there yet”. While, I do understand the reasoning behind the error, I don’t know how to solve the error in my situation.

    I have a master container that I load my sections into. Each section, or swf has “intro” & “outro” states so the transitions are smooth. I have this working properly with no issues.

    I’ve decided to add an XML gallery as another section, which has a corresponding Gallery.as file. I have it working properly on its own. However, if I add it to the master container, and run the movie, I get this:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Gallery()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Gallery/urlLoadComplete()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    Mind you, all movieclips and actions are on the first frame of my gallery.swf.

    Looks like this all has to do with the Gallery.as file. I’m wondering if this is a targeting/scope issue? Or, does my master container not realize the gallery.swf exists? According to your comments about the 1009 error, the movieclip isn’t instantiated yet. Not sure where to begin in this situation. The other sections work, why not this one? If you could at least point me in the right direction that would be fantastic. Any help would be greatly appreciated.

    If what I’m describing doesn’t make much sense, I could post my files.

  11. Hey,
    I got this error message:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at QuizApp/createQuestions()
    at QuizApp()

    after modifying an actionscript tutorial I found online to create an oop quiz application, this is the code, and I cannot figure out what the problem is :

    code:

    package {

    import flash.display.Sprite;
    import fl.controls.Button;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;

    public class QuizApp extends Sprite {
    //for managing questions:
    private var quizQuestions:Array;
    private var currentQuestion:QuizQuestion;
    private var currentIndex:int = 0;
    //the buttons:
    private var prevButton:Button;
    private var nextButton:Button;
    private var finishButton:Button;
    //scoring and messages:
    private var score:int = 0;
    private var status:TextField;
    //for randomizing
    private var tempArray:Array;
    private var quizLength:int;

    public function QuizApp() {
    quizQuestions = new Array();
    createQuestions();
    createButtons();
    createStatusBox();
    //added this function for randomizing
    mixQuestions();
    addAllQuestions();
    hideAllQuestions();
    firstQuestion();
    }
    private function createQuestions() {
    tempArray.push(new QuizQuestion(“What color is an orange?”,
    1,
    “Orange”,
    “Blue”,
    “Purple”,
    “Brown”));
    tempArray.push(new QuizQuestion(“What is the shape of planet earth?”,
    3,
    “Flat”,
    “Cube”,
    “Round”,
    “Shabby”));
    tempArray.push(new QuizQuestion(“Who created SpiderMan?”,
    2,
    “Jack Kirby”,
    “Stan Lee and Steve Ditko”,
    “Stan Lee”,
    “Steve Ditko”,
    “none of the above”));
    tempArray.push(new QuizQuestion(“Who created Mad?”,
    2,
    “Al Feldstein”,
    “Harvey Kurtzman”,
    “William M. Gaines”,
    “Jack Davis”,
    “none of the above”));
    quizLength = tempArray.length

    }

    private function mixQuestions() {
    for (var i:int = 0; i < quizLength; i++) {
    var randomValue:int = Math.floor(Math.random() * tempArray.length);
    quizQuestions.push(tempArray[randomValue]);
    tempArray.splice(randomValue,1);
    }
    }

    private function createButtons() {
    var yPosition:Number = stage.stageHeight – 40;

    prevButton = new Button();
    prevButton.label = "Previous";
    prevButton.x = 30;
    prevButton.y = yPosition;
    prevButton.addEventListener(MouseEvent.CLICK, prevHandler);
    addChild(prevButton);

    nextButton = new Button();
    nextButton.label = "Next";
    nextButton.x = prevButton.x + prevButton.width + 40;
    nextButton.y = yPosition;
    nextButton.addEventListener(MouseEvent.CLICK, nextHandler);
    addChild(nextButton);

    finishButton = new Button();
    finishButton.label = "Finish";
    finishButton.x = nextButton.x + nextButton.width + 40;
    finishButton.y = yPosition;
    finishButton.addEventListener(MouseEvent.CLICK, finishHandler);
    addChild(finishButton);
    }
    private function createStatusBox() {
    status = new TextField();
    status.autoSize = TextFieldAutoSize.LEFT;
    status.y = stage.stageHeight – 80;

    addChild(status);
    }
    private function showMessage(theMessage:String) {
    status.text = theMessage;
    status.x = (stage.stageWidth / 2) – (status.width / 2);
    }
    private function addAllQuestions() {
    for(var i:int = 0; i < quizQuestions.length; i++) {
    addChild(quizQuestions[i]);
    }
    }
    private function hideAllQuestions() {
    for(var i:int = 0; i 0) {
    currentQuestion.visible = false;
    currentIndex–;
    currentQuestion = quizQuestions[currentIndex];
    currentQuestion.visible = true;
    } else {
    showMessage(“This is the first question, there are no previous ones”);
    }
    }
    private function nextHandler(event:MouseEvent) {
    showMessage(“”);
    if(currentQuestion.userAnswer == 0) {
    showMessage(“Please answer the current question before continuing”);
    return;
    }
    if(currentIndex < (quizQuestions.length – 1)) {
    currentQuestion.visible = false;
    currentIndex++;
    currentQuestion = quizQuestions[currentIndex];
    currentQuestion.visible = true;
    } else {
    showMessage("That's all the questions! Click Finish to Score, or Previous to go back");
    }
    }
    private function finishHandler(event:MouseEvent) {
    showMessage("");
    var finished:Boolean = true;
    for(var i:int = 0; i < quizQuestions.length; i++) {
    if(quizQuestions[i].userAnswer == 0) {
    finished = false;
    break;
    }
    }
    if(finished) {
    prevButton.visible = false;
    nextButton.visible = false;
    finishButton.visible = false;
    hideAllQuestions();
    computeScore();
    } else {
    showMessage("You haven't answered all of the questions");
    }
    }
    private function computeScore() {
    for(var i:int = 0; i < quizQuestions.length; i++) {
    if(quizQuestions[i].userAnswer == quizQuestions[i].correctAnswer) {
    score++;
    }
    }
    showMessage("You answered " + score + " correct out of " + quizQuestions.length + " questions.");
    }
    }
    }

    Can u please tell me what the problem is and how i can solve it
    , thank you in advance!

  12. I am a complete newb when it comes to flash and actionscript 3. I have set up a button class and document class. In the button class I have code that defines what the text on the button will be. In the document class I have code that defines what the text on the instances of the button will be. I keep getting the error TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at siteButton/setLabel()
    at Website()

    This is my button class code (siteButton)
    package
    {

    import flash.display.SimpleButton;

    public class siteButton extends SimpleButton
    {

    public function siteButton()
    {
    trace(“siteButton has been cerated”)
    }
    public function setLabel(newLabel:String):void
    {
    this.buttonLabel.text = newLabel;
    }
    }
    }
    This is my document class code (Website)
    package
    {

    import flash.display.MovieClip;

    public class Website extends MovieClip
    {

    public function Website()
    {
    skipButton.setLabel(“Skip”);

    }

    }

    }
    I’m guessing that it’s trying to execute the function before it knows what it is. I just don’t know how to solve it.

  13. Hi,

    Here is my code and i am getting the below error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.effects.effectClasses::MoveInstance/play()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\effects\effectClasses\MoveInstance.as:239]
    at mx.effects::EffectInstance/startEffect()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\effects\EffectInstance.as:569]
    at mx.effects.effectClasses::ParallelInstance/play()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\effects\effectClasses\ParallelInstance.as:199]
    at mx.effects::EffectInstance/startEffect()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\effects\EffectInstance.as:569]
    at mx.effects::Effect/play()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\effects\Effect.as:930]
    at mx.core::UIComponent/commitCurrentState()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:7198]
    at mx.core::UIComponent/setCurrentState()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:7113]
    at mx.core::UIComponent/set currentState()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:4361]
    at Feedback/resulthandler()[C:\Documents and Settings\rakshith\My Documents\Flex Builder 3\Feedback\src\Feedback.mxml:220]
    at Feedback/__service1_result()[C:\Documents and Settings\rakshith\My Documents\Flex Builder 3\Feedback\src\Feedback.mxml:265]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at mx.rpc.http.mxml::HTTPService/http://www.adobe.com/2006/flex/mx/internal::dispatchRpcEvent()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\http\mxml\HTTPService.as:290]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:193]
    at mx.rpc::Responder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:43]
    at mx.rpc::AsyncRequest/acknowledge()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:74]
    at DirectHTTPMessageResponder/completeHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:403]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    Here is my code…
    Please do help me out::::

    <![CDATA[
    import mx.containers.Tile;
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    import mx.controls.Label;
    import mx.controls.Alert;
    import mx.rpc.events.ResultEvent;

    public var def_val:String=null;
    public var gotIt:ArrayCollection = new ArrayCollection();
    public var temp:Boolean;

    public var i:int=0;

    public function id_to_arr():void{
    gotIt= load_all_courses.lastResult.course_details.details ;
    }

    public function addFindReplaceButton():void {

    var but:Button = new Button();
    but.label = "Submit";

    user_feedback_text.toolbar.addChild(but);
    but.addEventListener(MouseEvent.CLICK,SendFeedback);

    }

    //Send the text to backend….
    private function SendFeedback(e:MouseEvent):void{
    temp = false;
    i=0;

    while(i

    {username.text}
    {password.text}

    {ncid.text}
    {ncname.text}
    {ninstructor.text}

    {ccid.text}
    {user_feedback_text.text}

    • RakShith – I apologize that the code was cut off. Your “while” statement is where it looks incomplete. Try using the “code” button on the comments before pasting.

      Thanks,

      Curtis J. Morley

  14. I fixed my problem… my frame1 for my main stuff was blank, because I thought I’d just have the loader. But then I simple put my main stuff under the loader – so it’s in all frames! The loader ends at frame1, but the main stuff goes from frame1 to frame2!

    MAKE SURE YOUR MAINSTUFF IS ON FRAME1 ALSO!!!!

  15. hey I’m making a short game for college and I’ve done all the code perfectly but that stupid error keeps coming up 🙁
    My code is :-
    var gameLoaded = false;

    stage.addEventListener(Event.ENTER_FRAME, game);
    playb.addEventListener(MouseEvent.CLICK, loadLevel1);

    function game (event)
    {
    trace(“check loopping”);

    if(gameLoaded == false)
    {
    playb.x = 150;
    }
    }

    function loadLevel1 (event)
    {
    trace(“loadlevel1”);
    playb.x = -2000;
    gameLoaded = true;
    }

    Any help please?

  16. I’m having a problem making a DVD Menu type thing. Basically, I have on the first frame the menu set up. When you click a button on the first frame, the code is supposed to take you to the second frame where it has the flvplayback and buttons on the bottom to return to the previous frame or navigate within the movie file. The second frame only controls previous cue point and next cue point. The problem I have is that I get the 1009 error code when test it. The code tells me, after debugging, that it’s on something in the first frame. After reading this thread, I looked as hard as I could. Below is my code. Can anyone help?

    first frame:

    stop();

    import fl.video.*;

    var url:String = (“http://PAL”);
    var request:URLRequest = new URLRequest(url);

    Intro.addEventListener(MouseEvent.CLICK, IntroMod);
    Test.addEventListener(MouseEvent.CLICK, TestBTN);
    Overview.addEventListener(MouseEvent.CLICK, OvrMod);
    PE.addEventListener(MouseEvent.CLICK, PEMod);
    OPM.addEventListener(MouseEvent.CLICK, OPMMod);
    PA.addEventListener(MouseEvent.CLICK, PAMod);
    AM.addEventListener(MouseEvent.CLICK, AMMod);
    RM.addEventListener(MouseEvent.CLICK, RMMod);
    PM.addEventListener(MouseEvent.CLICK, PMMod);
    DI.addEventListener(MouseEvent.CLICK, DIMod);
    SR.addEventListener(MouseEvent.CLICK, SRMod);
    PerfM.addEventListener(MouseEvent.CLICK, PerfMMod);
    CM.addEventListener(MouseEvent.CLICK, CMMod);
    OPTraining.addEventListener(MouseEvent.CLICK, OPMod);

    //Main Menu Buttons
    stop();

    function TestBTN(event:MouseEvent){
    navigateToURL(request);
    }

    function IntroMod(event:MouseEvent){
    gotoAndStop(2);
    this.Movie.seekToNavCuePoint(“Mod1”);
    this.Movie.play();
    }

    function OvrMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod2”);
    }

    function PEMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod3”);
    }

    function OPMMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod4”);
    }

    function PAMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod5”);
    }

    function AMMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod6”);
    }

    function RMMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod7”);
    }

    function PMMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod8”);
    }

    function DIMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod9”);
    }

    function SRMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod10”);
    }

    function PerfMMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod11”);
    }

    function CMMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod12”);
    }

    function OPMod(event:MouseEvent){
    gotoAndStop(2);
    Movie.seekToNavCuePoint(“Mod13”);
    }

    second frame:

    stop();

    //Playback Menu Buttons
    var i=1;
    var j=0;

    MMenu.addEventListener(MouseEvent.CLICK, MainMenu);
    Prev.addEventListener(MouseEvent.CLICK, PrevMod);
    Next.addEventListener(MouseEvent.CLICK, NextMod);

    function MainMenu(event:MouseEvent) {
    Movie.stop();
    this.gotoAndStop(1);
    }

    function PrevMod(event:MouseEvent) {
    Movie.seekToPrevNavCuePoint();
    Movie.play();
    }

    function NextMod(event:MouseEvent) {
    Movie.seekToNextNavCuePoint();
    Movie.play();
    }

    Any help?! PLEASE!!

  17. Hi, I got an output message that “TypeError: Error #1009: Cannot access a property or method of a null object reference.at flashSnow/::frame1() ”
    Here is my code:
    package {
    import flash.events.Event;
    import flash.display.SimpleButton;
    import flash.display.MovieClip;
    import flash.filters.BlurFilter;
    import flash.text.TextField;

    public class flashSnow extends MovieClip {
    public function flashSnow():void {
    stage.frameRate=30;
    stage.addEventListener(Event.ENTER_FRAME,createSnow);
    }
    function createSnow(IN_Event:Event):void {
    if (randomInRange(1,3)==1) {
    var mc_particle:MovieClip=createCircle(randomInRange(3,10));
    mc_particle.x=randomInRange(0,stage.stageWidth);
    mc_particle.id=randomInRange(0,2);
    mc_particle.filters=[new BlurFilter(10,10,2)];
    mc_particle.addEventListener(Event.ENTER_FRAME,moveSnow);
    addChild(mc_particle);
    }
    }
    function createCircle(radius:Number):MovieClip {
    var mc_circle:MovieClip =new MovieClip();
    mc_circle.graphics.beginFill(0xFFFFFF,1);
    mc_circle.graphics.drawCircle(0,0,radius);
    mc_circle.graphics.endFill();
    return (mc_circle);
    }
    function moveSnow(IN_Event:Event):void {
    if (IN_Event.target.y>stage.stageHeight) {
    IN_Event.target.removeEventListener(Event.ENTER_FRAME,moveSnow);
    removeChild(MovieClip(IN_Event.target));
    }
    IN_Event.target.y += (IN_Event.target.width)/10;
    if (IN_Event.target.id==0) {
    IN_Event.target.x += (IN_Event.target.width)/30; }
    else if (IN_Event.target.id==1) {
    IN_Event.target.x -= (IN_Event.target.width)/30;
    }
    }
    function randomInRange(min:Number,max:Number):Number {
    var scale:Number=max- (–min);
    return Math.ceil(Math.random() * scale + min);
    }
    }
    }

    Could you help me to solve it?

  18. Thanks to reading through this post carefully, I think I figured out a work-around. Any advice would still be great, but at least this gets my buttons to work.

    Thank you all for sharing and helping us all!

  19. I found this post to be the most helpful I’ve found so far on error #1009, but I am still wrestling the error myself!

    My AS3 (what I know of it) is very rusty, and I am relying on it to create a very simple portfolio website. I have all my main pages set up in different keyframes in a single timeline on one scene. All my main pages link perfectly through a set of six buttons. I want to have content in sub-pages linked the same way through buttons only existing on certain pages. I have the buttons set up with instances, and each time I try to write one into the code, it throws an error #1009. If I comment out that section of the code, I don’t get the error anymore. When I get the error, all my original buttons keep working- business as usual- but the new button refuses to work.

    Any thoughts? Here’s a sample of my code:

    stop();

    //Plays through to next page
    function goHome(event:MouseEvent):void
    {
    gotoAndStop(1);
    }

    //Sets the event listener for the about button
    home_btn.addEventListener(MouseEvent.CLICK, goHome);

    //Plays through to next page
    function goAbout(event:MouseEvent):void
    {
    gotoAndStop(20);
    }

    //Sets the event listener for the about button
    abt_btn.addEventListener(MouseEvent.CLICK, goAbout);

    //Plays through to next page
    function goPort(event:MouseEvent):void
    {
    gotoAndPlay(40);
    }

    //Sets the event listener for the about button
    port_btn.addEventListener(MouseEvent.CLICK, goPort);

    //Sets the event listener for the resume button
    res_btn.addEventListener(MouseEvent.CLICK, goRes);

    //Plays through to next page
    function goRes(event:MouseEvent):void
    {
    gotoAndPlay(71);
    }

    //Sets the event listener for the contact button
    con_btn.addEventListener(MouseEvent.CLICK, goCon);

    //Plays through to next page
    function goCon(event:MouseEvent):void
    {
    gotoAndStop(90);
    }

    //Sets the event listener for the scoop button
    scoop_btn.addEventListener(MouseEvent.CLICK, goScoop);

    //Plays through to next page
    function goScoop(event:MouseEvent):void
    {
    gotoAndStop(110);
    }

    //Sets the event listener for the fonts button
    //fonts_btn.addEventListener(MouseEvent.CLICK, goFonts);

    //Plays through to next page
    //function goFonts(event:MouseEvent):void
    //{
    // gotoAndPlay(130);
    //}

    The commented code at the end is what throws the error if I un-comment it.

    Any help would be sincerely appreciated!

  20. help
    This is the
    Error message im getting i cnat figure it out

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at arraygame_fla::MainTimeline/shotListener()

  21. Hello!
    I’m getting this error 1009 “TypeError: Error #1009: Cannot access a property or method of a null object reference. at website_flashvrsn_fla::Mainpg_mc_1/stopScroll()

    I am running a simple personal site where there are several buttons that display various data. When I initiate the button that has a custom vertical scroll function, I receive the error from that point forward when any button is activated. The code is as follows:

    scrollText.text = someText;
    scrollText.multiline = true;
    scrollText.wordWrap = true;

    var bounds:Rectangle = new Rectangle(scrollMC.x, scrollMC.y, 0, 68);
    var scrolling:Boolean = false;

    function startScroll (e:Event):void {
    scrolling = true;
    scrollMC.startDrag (false,bounds);
    }

    function stopScroll (e:Event):void {
    scrolling = false;
    scrollMC.stopDrag ();
    }

    scrollMC.addEventListener (MouseEvent.MOUSE_DOWN, startScroll);
    stage.addEventListener (MouseEvent.MOUSE_UP, stopScroll);

    addEventListener (Event.ENTER_FRAME, enterHandler);

    function enterHandler (e:Event):void {
    if (scrolling == true) {
    scrollText.scrollV = Math.round(((scrollMC.y – bounds.y)/68)*scrollText.maxScrollV);
    }
    }

    The site works but I just continually receive the error once I activate the scroll. I am seeking clean code :-). Any ideas, where I may have gone wrong? I appreciate your assistance!

    Regards,
    V
    IndesignCS5 into FlashCS5

  22. Hi, I’m getting these errors when I run my flash:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at EscapeTheFactory_fla::MainTimeline/F1C()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at EscapeTheFactory_fla::MainTimeline/F5A()

    The Script is as follows:

    stop();
    var V1:Boolean;
    V1 = false;
    var VName : String;
    VName = T1A.text;
    stage.focus = T2B;
    function F5A(eventObject:MouseEvent) {
    MC1.visible = true;
    if (T2B.text == “Red Pill”) {
    V1 = true;
    gotoAndStop(6);
    } else if (T2B.text == “Blue Pill”) {
    V1 = true;
    gotoAndStop(6);
    } if (V == false){
    T1A.text == “You can’t do that.” + VName;
    }
    }
    stage.focus = T2B;
    B1.addEventListener(MouseEvent.CLICK,F5A);

    ANY HELP WOULD BE GREATLY APPRECIATED! 😀

  23. I had the same problem.

    If the movie clip has a classic tween applied to it which means you have 2 keyframes. Check movieclip labels on both keyframes.

    Hope this helps.

  24. After pulling out my hair for about 4.5 hours with this error last night, I read this post (and the comments) and it helped me fix my file this afternoon. Thank you all for your posts, I finally feel sane again.

  25. I have around 20 buttons on my stage(fla file) who s instances are given in property bar…
    ->the buttons are animated in timeline

    and i want to give functionality to these buttons on click in external document file (.as file)

    the code which i wrote is

    package{
    import flash.display.MovieClip;
    import flash.events.*;
    import flash.events.Event;
    import flash.display.SimpleButton;
    import flash.events.MouseEvent;
    import flash.display.*;
    import flash.text.TextField;
    import flash.net.*;

    public class Main1 extends MovieClip
    {
    main.addEventListener(MouseEvent.CLICK,fmain);
    fullmap.addEventListener(MouseEvent.CLICK,ff);
    atomic.addEventListener(MouseEvent.CLICK,fatomic);
    radio.addEventListener(MouseEvent.CLICK,fradio);
    massenergy.addEventListener(MouseEvent.CLICK,fmassenergy);
    massdefect.addEventListener(MouseEvent.CLICK,fmassdefect);
    nuclear.addEventListener(MouseEvent.CLICK,fnuclear);
    constituent.addEventListener(MouseEvent.CLICK,fconstituent);
    rutherford.addEventListener(MouseEvent.CLICK,frutherford);
    thomsons.addEventListener(MouseEvent.CLICK,fthomsons);
    bohrs.addEventListener(MouseEvent.CLICK,fbohrs);
    types.addEventListener(MouseEvent.CLICK,ftypes);
    atoms.addEventListener(MouseEvent.CLICK,fatoms);
    fission.addEventListener(MouseEvent.CLICK,ffission);
    fusion.addEventListener(MouseEvent.CLICK,ffusion);
    reactor.addEventListener(MouseEvent.CLICK,freactor);
    radioactive.addEventListener(MouseEvent.CLICK,fradioactive);
    disintegration.addEventListener(MouseEvent.CLICK,fdisintegration);
    transmutation.addEventListener(MouseEvent.CLICK,ftransmutation);
    next11.addEventListener(MouseEvent.CLICK,fnext1);
    prev1.addEventListener(MouseEvent.CLICK,fprev1);

    public function Mainf():void{

    function fmain(Event:MouseEvent)
    {
    gotoAndPlay(2);
    trace(“i have clicked”);
    }
    function ff(Event:MouseEvent)
    {
    gotoAndStop(776);
    trace(“i have clicked”);
    }
    function fatomic(Event:MouseEvent)
    {
    gotoAndPlay(21);
    trace(“i have clicked”);
    }
    function fradio(Event:MouseEvent)
    {
    gotoAndPlay(291);
    }
    function fmassenergy(Event:MouseEvent)
    {
    gotoAndPlay(96);
    }
    function fmassdefect(Event:MouseEvent)
    {
    gotoAndPlay(116);
    }
    function fnuclear(Event:MouseEvent)
    {
    gotoAndPlay(136);
    }
    function fconstituent(Event:MouseEvent)
    {
    gotoAndPlay(236);
    }
    function frutherford(Event:MouseEvent)
    {
    gotoAndPlay(241);
    }
    function fthomsons(Event:MouseEvent)
    {
    gotoAndPlay(778);
    }
    function fbohrs(Event:MouseEvent)
    {
    gotoAndPlay(261);
    }
    function ftypes(Event:MouseEvent)
    {
    gotoAndPlay(376);
    }
    function fatoms(Event:MouseEvent)
    {
    gotoAndPlay(531);
    }
    function ffission(Event:MouseEvent)
    {
    gotoAndPlay(561);
    }
    function ffusion(Event:MouseEvent)
    {
    gotoAndPlay(621);
    }
    function freactor(Event:MouseEvent)
    {
    gotoAndPlay(641);
    }
    function fradioactive(Event:MouseEvent)
    {
    gotoAndPlay(651);
    }
    function fdisintegration(Event:MouseEvent)
    {
    gotoAndPlay(666);
    }
    function ftransmutation(Event:MouseEvent)
    {
    gotoAndPlay(691);
    }
    function fnext1(Event:MouseEvent)
    {
    gotoAndStop(777);
    }
    function fprev1(Event:MouseEvent)
    {
    gotoAndStop(776);
    }
    }
    }

    }

    where all buttons instances are on stage…..
    they are no errors but the problem is…the button is not calling the function on click

  26. Thanks

    I fixed the problem this morning…

    It was the following line in the MainClass() (the constructor).

    stage.showDefaultContextMenu = false;

    I am new to AS3.

    goodbye

  27. Sorry for my English. I am new to English language.

    I hope my post is clear.

    Thank you.

  28. Hi everyone!

    I’ve a problem and thanks in advance for your help.

    I’ve a swf acts as a loader for another swf. Let’s name them loaderSwf.swf and targetSwf.swf respectively. the targetSwf works just fine when it’s playing as stand-alone, but when I play the loaderSwf for loading the targetSwf I get the famous TypeError 1009 at MainClass(). The MainClass() is the main document class of the targetSwf. The following is the script of the loaderSwf.

    package
    {
    import flash.net.URLRequest;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.events.ProgressEvent;
    import flash.display.Sprite;

    public final class TestLoader extends Sprite
    {
    public function TestLoader()
    {
    startLoad();
    }

    private function startLoad()
    {
    var mLoader:Loader = new Loader();
    var mRequest:URLRequest = new URLRequest(“targetSwf.swf”);
    mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
    mLoader.load(mRequest);
    }

    private function onCompleteHandler(loadEvent:Event)
    {
    addChild(loadEvent.currentTarget.content);
    }

    private function onProgressHandler(mProgress:ProgressEvent)
    {
    var percent:Number = mProgress.bytesLoaded / mProgress.bytesTotal;
    //percentT.text = percent + ‘%’;
    trace(percent);
    }
    }
    }

    ——-
    Actually it’s stranger, at least logically, because the loader’s job is just loading the whole targetSwf at once not to play it sequentially! so after loading has been accomplished the targetSwf would take its place and then bear the responsibility for making each object known.

    Or perhaps I’m not logical enough in this case.

    Thanks again.

  29. i have a problem with error 1009.

    but my flash every thing is goin while.

    i put a script flvplayback.visible= false at frame 1.

    but my flvplayback is at the last frame.

    how to correct it?

    my flvplayer is connect wif xml. and it’s behind my contact or homepage if i didnt put visible=false.

  30. Hey

    I keep getting this problem with my code in scene 3 (of 3 for now, planning on adding a LOT more) of my game i’m doing for a class.

    Here’s the problem code:

    stop();
    Mouse.hide();
    this.stage.addEventListener(MouseEvent.MOUSE_DOWN, shotFired);
    this.stage.addEventListener(Event.ENTER_FRAME, moveSniperScope);

    function moveSniperScope(e:Event):void {
    sniperScope_mouse.x -= (sniperScope_mouse.x – mouseX) / 3;
    sniperScope_mouse.y -= (sniperScope_mouse.y – mouseY) / 3;
    }

    function shotFired(e:MouseEvent):void {
    if (sniperScope_mouse.sniperReticle_hit.hitTestObject(targetHead)){
    targetHead.alpha = .5 /*Determine Kill Shot*/
    }
    sniperScope_mouse.y = sniperScope_mouse.y – 60 /*Gun Recoil*/
    sniperScope_mouse.x = sniperScope_mouse.x + 40
    }

    I’ve triple checked the names of my objects, etc. and they are all correct. When I debug, it finds something wrong with line 7 [ sniperScope_mouse.x -= (sniperScope_mouse.x – mouseX) / 3; ]

    any idea what it might be?

    Thanks for your time =)

  31. I STill get the error plss help me….

    Red_btn.addEventListener(MouseEvent.CLICK, Link);
    function Link(event:MouseEvent):void {

    try {
    gotoAndStop(‘2′);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }
    Green_btn.addEventListener(MouseEvent.CLICK, Link2);
    function Link2(event:MouseEvent):void {

    try {
    gotoAndStop(’11’);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }
    Black_btn.addEventListener(MouseEvent.CLICK, Link3);
    function Link3(event:MouseEvent):void {

    try {
    gotoAndStop(’26’)
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }

    product_btn.addEventListener(MouseEvent.CLICK, callLink);
    function callLink(event:MouseEvent):void {
    var url:String = “products.htm”;
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, ‘_self’);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }
    gallery_btn.addEventListener(MouseEvent.CLICK, callLink2);
    function callLink2(event:MouseEvent):void {
    var url:String = “gallery.htm”;
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, ‘_self’);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }
    service_btn.addEventListener(MouseEvent.CLICK, callLink3);
    function callLink3(event:MouseEvent):void {
    var url:String = “service.htm”;
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, ‘_self’);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }
    staff_btn.addEventListener(MouseEvent.CLICK, callLink4);
    function callLink4(event:MouseEvent):void {
    var url:String = “staff.htm”;
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, ‘_self’);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }
    consult_btn.addEventListener(MouseEvent.CLICK, callLink5);
    function callLink5(event:MouseEvent):void {
    var url:String = “consult.htm”;
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, ‘_self’);
    } catch (e:Error) {
    trace(“Error occurred!”);
    }
    }

  32. i actually just found the answer by reviewing the code and comparing with other arrows…

    Moral of the story, always readm take your time, and if you have other things that seem to workk : COMPARE !

  33. Hi !
    I’m having this error 1009 on different elements, and have no idea why, to be honest… My flash project is a little dance game, using keyboard arrows… It compiles properly and all… but when I start playing/testing i get this error everytime i press the Up arrow…
    Just to mention: i created this game following a tutorial, but i decided to add a video after (but I’m no ActionScript genius… I’m still struggling everytime I deal with bits of code)

    Here’s what it says:

    “TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at UrbanDancer_fla::MainTimeline/pressKey()”

  34. It’s ok i’ve found it! I had put a clip and delete him after (my attend was to only delete the background of the clip…) Thx god can keep move on 😀

  35. Hello everyone, i apologizes if my english isn’t correct but i have only learn for 1 year.

    I’ve got this error 1009 and i’m stuck in it from 3 day now and i wonder if anyone could help me.

    Sorry but the comments and variables are in french
    ———————————————————
    //
    //—————————————————————- INITIALISATIONS —//
    //
    var portfolioXML:XML;
    var chargeDonnees:URLLoader = new URLLoader();
    var adresseFichier:URLRequest=new URLRequest(“portfolio.xml”);
    //— Variable qui va permettre de scroller d’un projet à l’autre —
    var index:Number=0;
    var categorie:String=”graphisme”;
    this.infoChargement.visible = true;
    this.infoChargement.text = “Section cours de chargement…”;
    //
    //— Importation de la class Tween —
    //
    import fl.transitions.*;
    import fl.transitions.easing.*;
    //
    //——————————————————————– FONCTIONS —//
    //
    //
    //— Fonction qui affecte les données chargées à une variable —
    //
    function chargementFini(event:Event) {
    infoChargement.visible = false;
    portfolioXML=new XML(chargeDonnees.data);
    chargeProjet(categorie);
    }
    //
    //— Fonction qui charge les projets d’une section —
    //
    function chargeProjet(categorieP:String) {
    //— On détermine le nombre de projets
    var nbProjets:Number=portfolioXML[categorieP].children().length();
    //
    //
    //
    for (var i=0; i < nbProjets; i++) {
    //
    //— On place le bouton —
    //
    var boutonP:bProjet=new bProjet ;
    boutonP.x=10;
    boutonP.y=45*i;
    boutonP.name=”bProjet”+i;
    addChild(boutonP);
    boutonP.indexProjet=index;
    boutonP.texteBouton.text = i+1;
    //
    //— On définit l’action du bouton —
    //
    boutonP.addEventListener(MouseEvent.CLICK, afficheProjet);
    //
    //— On charge les infos du projet —
    //
    var projetC:clipProjet=new clipProjet ;
    projetC.y=boutonP.indexProjet;
    projetC.name=”clipProjet”+i;
    sections.addChild(projetC);
    //— Nom du projet —
    projetC.nomProjet.text = portfolioXML[categorieP].projet[i].@nom;
    //— Type de projet —
    projetC.typeProjet.text = portfolioXML[categorieP].projet[i].@typeProjet;
    //— Descriptif du projet —
    projetC.descriptionProjet.text = portfolioXML[categorieP].projet[i];
    //
    //— L’image du projet —
    //
    chargeImage(portfolioXML[categorieP].projet[i].@image, projetC.imageProjet);
    //
    //— On incrémente l’index : pour les futurs positions des autres projets —
    //
    index+=470;
    }
    }
    //
    //— Fonction qui charge les images —
    //
    function chargeImage(url:String, cible:Object) {
    var loaderImage:Loader = new Loader();
    var urlImage:URLRequest = new URLRequest(url);
    loaderImage.load(urlImage);
    cible.addChild(loaderImage);
    }
    //
    //— Fonction qui scroll d’un projet à l’autre —
    //
    function afficheProjet(event:MouseEvent) {
    var deplaceSections:Tween = new Tween(sections, “y”, Strong.easeOut, sections.y, -event.currentTarget.indexProjet, 1, true);
    }
    //
    //——————————————————————– ECOUTEURS —//
    //
    chargeDonnees.load(adresseFichier);
    chargeDonnees.addEventListener(Event.COMPLETE,chargementFini);

    ———————————————————

  36. hi every body

    i am new in flex and action script.

    i have one form that i add it formItems and it was worked very well after added textInput and when i want to access to textInput text it gives me thid error.

    i am just freaking out , i don’t know couse of this error ,i have another formItem with comboBox element and i can access to value of selectedItem in that very easily.please if you have any ideas about this error please help me

    thanks.

    my code

    in this state i am adding one comboBox and two textInput to the form

    and in this part of cod i handle event of button click where error occur

    case “rep_shek_tedad”:
    if(state.selectedItem != null){
    stateSelectedItem = state.selectedItem;
    srv.getShekayatCount(stateSelectedItem.data,dateInput.text,dateInput1.text);
    }else {
    srv.getShekayatCount(null,this.dateInput.text,this.dateInput1.text);
    }
    currentState = ‘enterCharts’;

  37. …LOL sorry for the gramatical and syntax mistakes…it’s the excitement!

    Carla Castro

  38. You are just what we need! Thank you so much! How can you easlily explain things is just “WOW…it makes sense!”. Thank you so much!

    You havehelped me and my uni project and to enjoy AS3.0 Flash CS4…so much fun!

    Long Live Morley!!

  39. Thank you! Thank you! Thank you for your post of 2 and a half years ago! I have been banking my head on the wall for more than 2 hours trying to get a button to work. I can’t believe it was such a simple a solution . . . introducing the code after the button appears on the timeline. Duh!

  40. You saved my life with this explanation for this Null Object Reference. All day I’ve spent trying to figure it out, Googling all sorts of complex code stuff. All I needed was this simple explanation.

    Many, many thanks.

    Best Wishes

    Jonathan Frewin

  41. For the stage problem in ended up put stage into from the timeline into the class in order to get it work.

    Ex:
    public class (bla bla bla…) {
    private var $s;
    public function “class name”(s):void {
    // s is stage u put in from timeline then you use $s instead of stage inside the class
    $s = s;
    }
    }

    not the best solution.. but it works without getting errors

  42. Hey.
    I’m new to flash and trying simply to create a link from a button on the site to another page on the site. I’ve given the button the same name and even instance name as the label on the frame I’m trying to link to. I’m getting this error when I test my movie:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at index_fla::MainTimeline/frame85()
    at flash.display::MovieClip/gotoAndStop()
    at index_fla::MainTimeline/clickSection()

    This is my code:

    stop();

    recordingsdontlook_mc.addEventListener(MouseEvent.CLICK, dontlookClick);

    function dontlookClick(evtObj:MouseEvent) {
    gotoAndStop(evtObj.target.name);
    }

    Can’t figure out why this is not working….
    Could someone please help?
    Thankyou

  43. Got it. Found it here: http://www.flepstudio.org/forum/actionscript-3-0-newbies/1906-load-external-swf-error-1009-a.html

    I needed to fire an ADDED_TO_STAGE event from the external SWF. Not sure I fully understand the solution, but it is working great now.

    Used AS2 for a few years and got good at it. Did other stuff for a couple of years and came back to AS3. If Adobe is hoping to thin the Flash herd a bit, AS3 will do it. MS threw Silverlight out there to compete and be “easy”, but its just another MS bumble.

    Thanks for again for maintaining the site. It is very useful and is now in my favorites. Maybe I’ll be able to pitch-in to the support end soon.

  44. Thanks for the explanation of the mysterious Error #1009. I’m using AS3. I have a container SWF (using a document class) that loads an external SWF. It was working well and then started failing with the 1009 error. I load an XML file. When that load is complete, I use data from the XML file to load the proper SWF. Seems so simple. I’ve stripped down the container SWF’s doc class to simply the code that follows. Should also note that the external SWF runs error free on its own. If I take out the very last line that actually LOADS THE SWF … no error. It seems like the objects are added in the proper order. Maybe something with latency in loading?? Thanks for any help/insight that you can provide.

    package src.container
    {

    //import fl.controls.ProgressBar;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.xml.*;
    import flash.net.*;
    import flash.utils.*;

    public class Container extends MovieClip
    {

    public function Container():void
    {

    // Loading objects for module data
    var moduleMC;
    var externalModule:MovieClip;
    var courseDataXML:XML;
    var swfLoader:Loader;
    var swfLoaderRequest:URLRequest;
    var moduleList:XMLList;

    // Load XML containing course listing
    var xmlURL:String = “data/course.xml”;
    var requestFile:URLRequest = new URLRequest(xmlURL);
    var loader:URLLoader = new URLLoader(requestFile);
    loader.addEventListener(Event.COMPLETE, xmlLoaded);

    // Function to take action after course listing XML loading is complete
    function xmlLoaded(e:Event):void
    {
    //Create load module data
    courseDataXML = new XML(e.target.data);
    moduleList = courseDataXML.module;

    // Load default module using first item’s src value
    swfLoaderRequest = new URLRequest(courseDataXML.module[0].@src);
    swfLoader = new Loader();
    addChildAt(swfLoader, 0);
    swfLoader.load(swfLoaderRequest);

    }
    }
    }
    }

  45. Im getting this Error:PLEASE HELP!
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    Im traing load my slide show using classes and place them on my site on gallery page( site for pages) when I load the slide show document on a single fla file it works but how to make it work in some other mc or some other frames?
    Thx

  46. Hello, Mr. Morley.. I started learning Flex by myself yesterday and tried writing this code.. After correcting numerous compiler errors, I encountered error #1009 for the following code. I would be extremely thankful if you could help me with it.. Thank you..

  47. TypeError: Error #1009: Cannot access a property or method of a null object reference.

    Guys! What I am doing is trying to use this application located here –
    http://weblog.cahlan.com/2006/09/uploading-files-with-flex-and-php.html#links

    Basically, the app is to select multiple files from your HD and upload it to any other computer/server. As I click add it lets me browse my HD but then when I select the file gives me that error.

    If I am using this application directly then it works. As I am trying to use this app in my application where I resize it and drop it in a corner then its giving me the above mentioned error. I have not reached to a stage where I can change the code as yet.

    The code for this app is located here- http://weblog.cahlan.com/files/file_uploads/srcview/index.html

    Any help is appreciated. Thanks in advance.

  48. Thanks so much for providing this info. I’m a self taught flash page designer and am having a real problem understanding certain aspects of AS3.0.

    AS3.0 forums (I’ve been to 4) have been pretty useless in providing me with answers thus far … cuz the answer appears to be SO simple that no one has the time to provide a helpful hint ….

    I never would have thought that I would have found the solution on a blog ….

    I’m bookmarking this site and coming back to read some more!

    Thank you thank you thank you!

  49. I, like Josh above, was about to endure some head trauma due to this issue, but you solved it for me! I had a replay button fading in. On the same frame # when the button is at 100% alpha it gets “instantiated” (what an amazing word, though I would’ve assumed the term is “instanced”) I also had the code telling the movie to gotoAndPlay frame 1. Nothing was working until I simply gave the beginning of the alpha fade the same instance name as when it gets to 100%.

    Bravo!

  50. Thank you so much !!! You can not even imagine what a BIG help was this post for me! Thank you once again and take care 🙂

  51. I am trying to simply link a URL using a button… here is the very simple code…

    blogbtn.addEventListener(MouseEvent.CLICK, onMouseClick);

    function onMouseClick(e:MouseEvent):void

    {
    var request:URLRequest = new URLRequest(“http://www.apple.com”);
    navigateToURL(request,”_blank”);

    }

    my button is named blogbtn however.. when I move to the frame where the button is located I get this output error before I even click the button. The button doesn’t work.

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at working1_fla::MainTimeline/frame52()
    at flash.display::MovieClip/gotoAndStop()
    at working1_fla::MainTimeline/eventResponseweb4()

    Why would it say that something not even related to the btn would be messing up?

    when I start a brand new flash file, the exact same code works perfectly so why is this code causing me so much pain? thanks.

  52. TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at PORTFOLIOfinal_fla::MainTimeline/frame111()

  53. Hi
    I was wondering if you would be able to help me.
    I Have the error coming up but I am using frame labels and there is content
    where the labels are. It is not inside of a movie. So I don’t know what to do :/

    Any help would be appreciated! Thank you!

  54. Thanks so much. I spent ages reading forums and other sites trying to figure out this problem before I stumbled on this site. After that, I solved the problem in less than five minutes!

  55. This is my script and the error is below. can anyone help me please

    package
    {
    import caurina.transitions.*;
    import flash.display.*;
    import flash.events.*;
    import caurina.transitions.properties.*;

    public dynamic class _bgImgMc extends flash.display.MovieClip
    {

    public function _bgImgMc()
    {
    super();
    addFrameScript(0, frame1);
    return;
    }

    public function _rtoBgFnc(arg1:flash.events.Event):*
    {
    sw = stage.stageWidth;
    sh = stage.stageHeight;
    _ldngMc.x = sw – 30;
    if (_ldBol && _actvTyp == “static”)
    {
    _cntnr.x = (sw – _cntnr.width) / 2;
    _cntnr.y = (sh – _cntnr.height) / 2;
    }
    return;
    }

    public function _imgFnc(arg1:String, arg2:String, arg3:String, arg4:String):*
    {
    if (arg1 == “null”)
    {
    _actv = false;
    }
    else
    {
    _actvTyp = arg4;
    _ldngMc.alpha = 1;
    _cntnr.x = 0;
    _cntnr.y = 0;
    if (_actvTyp == “static”)
    {
    mc = new Images(arg1, false);
    _cntnr.addChild(mc);
    _cntnr.alpha = 0;
    }
    if (_actvTyp == “dynamic”)
    {
    mc1 = new Images(arg1, false);
    mc2 = new Images(arg2, false);
    mc3 = new Images(arg3, false);
    _cntnr.addChild(mc1);
    _cntnr.addChild(mc2);
    _cntnr.addChild(mc3);
    _cntnr.alpha = 0;
    }
    _actv = true;
    _ldBol = false;
    addEventListener(flash.events.Event.ENTER_FRAME, _ldrFnc);
    }
    return;
    }

    public function _go(arg1:String, arg2:String, arg3:String, arg4:String):*
    {
    var _pth:String;
    var _pth2:String;
    var _pth3:String;
    var _typ:String;

    var loc1:*;
    _pth = arg1;
    _pth2 = arg2;
    _pth3 = arg3;
    _typ = arg4;
    if (_actv)
    {
    caurina.transitions.Tweener.addTween(_cntnr, {“alpha”:0, “time”:0.5, “onComplete”:function ():*
    {
    if (_actvTyp != “static”)
    {
    mc1._dltObj();
    mc2._dltObj();
    mc3._dltObj();
    delete _cntnr.getChildAt(0);
    delete _cntnr.getChildAt(1);
    delete _cntnr.getChildAt(2);
    _cntnr.removeChild(mc1);
    _cntnr.removeChild(mc2);
    _cntnr.removeChild(mc3);
    removeEventListener(flash.events.Event.ENTER_FRAME, procs);
    }
    else
    {
    mc._dltObj();
    delete _cntnr.getChildAt(0);
    _cntnr.removeChild(mc);
    }
    _imgFnc(_pth, _pth2, _pth3, _typ);
    return;
    }})
    if (!_ldBol)
    {
    removeEventListener(flash.events.Event.ENTER_FRAME, _ldrFnc);
    }
    }
    else
    {
    _imgFnc(_pth, _pth2, _pth3, _typ);
    }
    return;
    }

    function frame1():*
    {
    _actv = false;
    _cntnr = new flash.display.Sprite();
    addChild(_cntnr);
    stage.addEventListener(flash.events.Event.RESIZE, _rtoBgFnc);
    _rtoBgFnc(null);
    return;
    }

    public function _ldrFnc(arg1:flash.events.Event):*
    {
    if (_actvTyp != “static”)
    {
    if (mc1._ldBol && mc2._ldBol && mc3._ldBol)
    {
    _ldBol = true;
    removeEventListener(flash.events.Event.ENTER_FRAME, _ldrFnc);
    addEventListener(flash.events.Event.ENTER_FRAME, procs);
    caurina.transitions.Tweener.addTween(_cntnr, {“alpha”:1, “time”:0.5});
    _ldngMc.alpha = 0;
    }
    }
    else
    {
    if (mc._ldBol)
    {
    _ldBol = true;
    removeEventListener(flash.events.Event.ENTER_FRAME, _ldrFnc);
    caurina.transitions.Tweener.addTween(_cntnr, {“alpha”:1, “time”:0.5});
    _ldngMc.alpha = 0;
    _rtoBgFnc(null);
    }
    }
    return;
    }

    public function procs(arg1:flash.events.Event):*
    {
    sw = stage.stageWidth;
    sh = stage.stageHeight;
    _initXScr = (-mouseX) / 1.5;
    _xScr = mc1.x;
    _dvScr = _initXScr – _xScr;
    _mvrScr = _dvScr / 10;
    mc1.x = _xScr + _mvrScr;
    _initXScr2 = (-mouseX) / 1.5;
    _xScr = mc2.x;
    _dvScr = _initXScr2 – _xScr;
    _mvrScr = _dvScr / 15;
    mc2.x = _xScr + _mvrScr;
    _initXScr3 = (-mouseX) / 1.5;
    _xScr = mc3.x;
    _dvScr = _initXScr3 – _xScr;
    _mvrScr = _dvScr / 18;
    mc3.x = _xScr + _mvrScr;
    return;
    }

    public var _actv:Boolean;

    public var _initXScr:Number;

    public var _dvScr:Number;

    public var _initXScr2:Number;

    public var mc1:Images;

    public var mc3:Images;

    public var mc2:Images;

    public var _xScr:Number;

    public var sw:Number;

    public var sh:Number;

    public var _ldBol:Boolean;

    public var _actvTyp:String;

    public var _mvrScr:Number;

    public var mc:Images;

    public var _initXScr3:Number;

    public var _ldngMc:_ldrMc;

    public var _cntnr:flash.display.Sprite;
    }
    }

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at _bgImgMc/_ldrFnc()

  56. I am trying to fix a problem that I am having with Flash.

    I get the following error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at nov_09_fla::MainTimeline/frame1()
    at flash.display::MovieClip/gotoAndStop()
    at nov_09_fla::MainTimeline/clickSection()

    I do not have a MovieClip in my Flash??? Here is my code on frame 1:

    stop();

    //handle events for buttons…
    calendar.addEventListener(MouseEvent.CLICK, clickSection);
    home.addEventListener(MouseEvent.CLICK, clickSection);
    pickerel.addEventListener(MouseEvent.CLICK, clickSection);
    contact.addEventListener(MouseEvent.CLICK, clickSection);

    function clickSection(evtObj:MouseEvent){
    //trace shows what’s happening.. in the output window
    trace (“The “+evtObj.target.name+” button was clicked!”)
    //go to the section clicked on…
    gotoAndStop(evtObj.target.name);
    }

  57. Hey all,

    I have a few classes I need to be linked together. I have a Ball class which just makes an instance of a ball. Then I have a Throwing class which calls the Ball class and has a bunch of math that makes it able to be thrown around. Then I have a parrallax scrolling class which I need to import/instantiate the Throwing class but when I attempt I get this wretched error. I am doing this for a class and we’ve had it for two weeks but I just can’t figure it out. Thanks in advance for any help!!

  58. ei i got this problem to
    now i know what caused the problem

    i forget to give my buttons the instanse name
    and i put a instanse name and the problem is gone

    ——————————————–
    tenia el mismo problema pero vi que es lo que causaba el problema
    se me habia olvidado poner el instanse name de mis botones
    asi que les puse y el probleme se resolvio, espero que puedan hacer lo mismo

  59. Hi Curtis,
    Thank you for speaking English in your explanation instead of programmer language. Your explanation was the first one I finally understood and I was able to fix the error! So, for us beginners, keep speaking in plain and simple terms. I will try your site for other issues I may come across (once I learn more).
    Lisa

  60. I got the error with just creating a simple button which takes you to another frame… after I got fed up looking for answers I made an alpha 0% block over the area and gave it the same code… worked.

    I am still too used to AS2

  61. Thanks for explaining this error in simple-to-understand terms.

    I had a straightforward animation for a website splash page that would finish with a stopped frame and two buttons would appear to allow the visitor to choose the language they would prefer.

    Running a test yielded the 1009 error. There is a stop(); action to freeze the animation and two button instances that would each call a URLRequest function. In accordance with your instructions, I simply inserted one extra frame just before the frame where the function calls adds an event listener and refers to my button instances. As long as the instances have been added to the stage before the script, no error should appear. And it worked!

    This ActionScript 3.0 stuff ain’t easy.

  62. OK if anyone makes it down this far and hasen’t solved their problem, try this.

    If your refering to a button in your movie

    e.g.

    button1.addEventListener(MouseEvent.CLICK,clickon1);

    make sure that every button on the stage is labeled…

    if you have a tween make sure that both buttons are labeled

    check to make sure you don’t have a duplicate button that is not labeled

    laying underneath the button you have labeled.

    Hope this helps,

    I lost 2 nights of sleep over this. I still miss AS2

  63. Hello,

    I just came across 1009 and got puzzled at first, had no clue what was wrong. I had an .FLA with some code using a TextArea component. Yes, I did have a TextArea component in my library and yes, I was importing fl.controls.*.

    When I tried loading this SWF in another SWF, I got this error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at fl.controls::TextArea/drawLayout()
    at fl.controls::TextArea/draw()
    at fl.core::UIComponent/callLaterDispatcher()

    It’s probably obvious why I got this error, but it took me 30 minutes to figure it out: I also needed to have the TextArea component in the library of the main SWF.

  64. hi iam newb to flash.
    i am been harrased by this error 1009
    iam trying to make a movieclip visible only after a button click am doing this via external .asfile
    intially on ythe stage my mc is not visible
    plz help me

  65. Thanks for the GREAT straight forward advice on that error after I read Fix 1 I knew exactly what the problem was!

    Thanks!
    jkr-

  66. I am using Flash CS4/AS3. I simply copy the code from http://www.learningactionscript3.com/download/ (Chapter 7–>Particle System) Particle to a new AS file and I get the Error #1009 at Particle/onRun().

    I didn’t change anything in the code just created a new file, copied the contents from Particle.as, delete original file, named new file Particle.as, replaced the old file.

    What could the problem be, Curtis?

  67. I’m getting so frustrated, I’m building a photo gallery and keep getting this error. Please forgive me because I’m pretty new to AS3.

    I have 11 thumbnails at the bottom of my stage, 4 of which appear on stage at a time. Every time an instance of the RightArrow button is pressed, the functionality is intended to play a certain scene (labeled). These scenes scroll the image bar so 2 additional thumbnails are available for viewing.

    I have the exact same code (except for instance names on frame1 and frame20, and it’s working as it should.

    Frame1:
    stop();

    import flash.events.MouseEvent;

    R_Arrow1.addEventListener(MouseEvent.CLICK, RArrow1);

    function RArrow1(event:MouseEvent):void{
    gotoAndPlay(“page1”);
    }

    Frame 20:
    stop();

    R_Arrow2.addEventListener(MouseEvent.CLICK, RArrow2);

    function RArrow2(event:MouseEvent):void{
    gotoAndPlay(“page2”);
    }

    Now, when I get to frame 40, I gave the RightArrow an instance name of R_Arrow3 and this is the code:

    stop();

    R_Arrow3.addEventListener(MouseEvent.CLICK, RArrow3);

    function RArrow3(event:MouseEvent):void{
    gotoAndPlay(“page3”);
    }

    No syntax errors, but when I play the movie and try clicking the RightArrow the third time I get a compiler error of:

    “TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at wedding_gallery_fla::MainTimeline/frame40()”

    Any ideas? Thanks so much!

  68. Hi all,

    I am new to ActionScript and Flash, and I am getting this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at jessicaclucas_fla::MainTimeline/stopResumescroll()

    I have several different clips in one movie that have scrolling content. When I click a button to move to a different clip that doesn’t have a certain scroll, it gives me this error. I cannot figure out how to fix this. You can see the site I am working on: http://www.jessicaclucas.com. I would really appreciate some help! Thank you in advance. Here is the code:

    //Import TweenMax and the plugin for the blur filter
    import gs.TweenMax;
    import gs.plugins.BlurFilterPlugin;

    //Save the content’s and mask’s height.
    //Assign your own content height here!!
    var RESUMECONTENT_HEIGHT:Number = 1500;
    var RESUME_HEIGHT:Number = 450;

    //We want to know what was the previous y coordinate of the content (for the animation)
    var oldResumeY:Number = myResumecontent.y;

    //Position the content on the top left corner of the mask
    myResumecontent.x = myResume.x;
    myResumecontent.y = myResume.y;

    //Set the mask to our content
    myResumecontent.mask = myResume;

    //Create a rectangle that will act as the Resumebounds to the scrollMC.
    //This way the scrollMC can only be dragged along the line.
    var Resumebounds:Rectangle = new Rectangle(resumescrollMC.x,resumescrollMC.y,0,450);

    //We want to know when the user is Resumescrolling
    var Resumescrolling:Boolean = false;

    //Listen when the user is holding the mouse down on the scrollMC
    resumescrollMC.addEventListener(MouseEvent.MOUSE_DOWN, startResumescroll);

    //Listen when the user releases the mouse button
    stage.addEventListener(MouseEvent.MOUSE_UP, stopResumescroll);

    //This function is called when the user is dragging the scrollMC
    function startResumescroll(e:Event):void {

    //Set Resumescrolling to true
    Resumescrolling = true;

    //Start dragging the scrollMC
    resumescrollMC.startDrag(false,Resumebounds);
    }

    //This function is called when the user stops dragging the scrollMC
    function stopResumescroll(e:Event):void {

    //Set Resumescrolling to false
    Resumescrolling = false;

    //Stop the drag
    resumescrollMC.stopDrag();
    }

    //Add ENTER_FRAME to animate the scroll
    addEventListener(Event.ENTER_FRAME, enterResumeHandler);

    //This function is called in each frame
    function enterResumeHandler(e:Event):void {

    //Check if we are Resumescrolling
    if (Resumescrolling == true) {

    //Calculate the distance how far the scrollMC is from the top
    var distance:Number = Math.round(resumescrollMC.y – Resumebounds.y);

    //Calculate the percentage of the distance from the line height.
    //So when the scrollMC is on top, percentage is 0 and when its
    //at the bottom the percentage is 1.
    var percentage:Number = distance / RESUME_HEIGHT;

    //Save the old y coordinate
    oldResumeY = myResumecontent.y;

    //Calculate a new y target coordinate for the content.
    //We subtract the mask’s height from the contentHeight.
    //Otherwise the content would move too far up when we scroll down.
    //Remove the subraction to see for yourself!
    var targetY:Number = -((RESUMECONTENT_HEIGHT – RESUME_HEIGHT) * percentage) + myResume.y;

    //We only want to animate the scroll if the old y is different from the new y.
    //In our movie we animate the scroll if the difference is bigger than 5 pixels.
    if (Math.abs(oldResumeY – targetY) > 5) {

    //Tween the content to the new location.
    //Call the function ResumetweenFinished() when the tween is complete.
    TweenMax.to(myResumecontent, 0.3, {y: targetY, blurFilter:{blurX:22, blurY:22}, onComplete: ResumetweenFinished});
    }
    }
    }

    //This function is called when the tween is finished
    function ResumetweenFinished():void {

    //Tween the content back to “normal” (= remove blur)
    TweenMax.to(myResumecontent, 0.3, {blurFilter:{blurX:0, blurY:0}});
    }

  69. Oh sorry, I forgot to add the code for the other frame, its the following:

    stop();
    function mainFrame(event:MouseEvent):void
    {
    gotoAndPlay(“start”);

    }
    homeBtn.stage.addEventListener(MouseEvent.CLICK, mainFrame);

    pdf.addEventListener(MouseEvent.CLICK, onMouseClick);
    function onMouseClick(event:MouseEvent):void
    {
    var targetURL:URLRequest = new URLRequest(“http://www.engsoc.net/~agutier2/images/Resume/AGutierrez.pdf”);
    navigateToURL(targetURL);
    }

    w2003.addEventListener(MouseEvent.CLICK, Clicking);
    function Clicking(event:MouseEvent):void
    {
    var targetURL:URLRequest = new URLRequest(“http://www.engsoc.net/~agutier2/images/Resume/AGutierrez.doc”);
    navigateToURL(targetURL);
    }
    w2007.addEventListener(MouseEvent.CLICK, Clicker);
    function Clicker(event:MouseEvent):void
    {
    var targetURL:URLRequest = new URLRequest(“http://www.engsoc.net/~agutier2/images/Resume/AGutierrez.docx”);
    navigateToURL(targetURL);
    }

    thanks once again… really really thanks a lot…

  70. Hi all,

    I’ve had my share on Flash with Actionscript 2.0, however getting used to Actionscript 3.0 seems to be very difficult for some reason. I keep trying to add an action to a button which is impossible.

    I’m currently working on my web-portfolio but I’m really stuck with this same error… 1009 really has me hanging by the ears…

    my code is:

    stop();

    two.stage.addEventListener(MouseEvent.CLICK, clicked);
    function clicked(event:MouseEvent):void
    {
    gotoAndPlay(“resume”);
    // This part is in case I decide to call it on another page
    //var targetURL:URLRequest = new URLRequest(“http://www.engsoc.net/~agutier2/Resume.html”);
    //navigateToURL(targetURL);
    }

    if you visit my website (www.engsoc.net/~agutier2) you can see that “two” is the ‘resume’ button… I don’t have a problem with that, it goes to the resume frame, but once I click on the button to go back (nameless button) I get the error…

    could anyone please please help?? I’d really appreciate it a lot…

  71. Hi Curtis – thanks for the great advice on your weblog. I’m relatively new to CS4 / AS3 although I’ve been dabbling with Flash for a few years. Just a simple question wrt the original 1009 errors. Frame 1… When the AS3 is compiled at runtime along with the layers of the timeline, is there a specific order that the compilation takes place. My timeline only has one frame but 10 layers. I lay items out on the stage and give them instance names on the lower layers (bottom) and my AS3 is on the top layer. I still get 1009 errors. Does this have anything to do with the order of compilation of the layers? Thanks.

  72. I’m also “new” to Flash and am making animations for our landing pages. I have not had this error before. I have made several of these. But this time one of the graphics to be clicked on is of a “coupon” that is buried in our site. Click on the graphic (set to alpha 0 as it fades in) and it takes you to the place where it is kept on the site. I “tested” the movie and at first the page comes up…followed by the error message in the OUTPUT tab. Here is the code. Please help! Thank you, Maureen.

    function gotoMASpecialsSite(event:MouseEvent):void
    {
    var maCouponURL:URLRequest = new URLRequest(“http://www.icomamerica.com/en/promotions/marine/SummerSavings/Default.aspx”);
    navigateToURL(maCouponURL,”_blank”);
    }
    marineSavings_lp.addEventListener(MouseEvent.CLICK, gotoMASpecialsSite)

  73. UPDATE: RESOLVED

    i decided to put the map in a movie clip and the solved it
    Thnx all.

  74. UPDATE:

    i narrowed down my problem, and it doesn’t look its fit for this forum. it appears there’s a problems w/ Google Map’s setSize.

    i eliminated all the code in the loadXML function to the bare minimum and if i put:

    var map:Map = new Map();
    map.key = “your_api_key”;
    map.setSize(new Point(stage.stageWidth, stage.stageHeight));
    this.addChild(map);

    it WILL give me a map in googlemap.swf but WITH the 1009 error in main.swf

    if i put:

    var map:Map = new Map();
    map.key = “your_api_key”;
    map.width = 550;
    map.height = 550;
    this.addChild(map);

    it WONT give me a map but it will load OK in main.swf

    if anyone has ran into similar issue or knows a work around, i’d still appreciate some help

    Thank you.

  75. i, too, get the 1009 error. i’m trying to load googlemaps.swf. the code in main.swf is:

    mapBtn.addEventListener(MouseEvent.CLICK, bringMap);
    function bringMap(event:MouseEvent):void {
    var mapLoader:Loader = new Loader();
    var mapURL:URLRequest = new URLRequest(“googlemaps.swf”);
    mapLoader.load(mapURL);
    }

    googlemaps.swf pulls data from events.xml file. the load function on the is:

    var xmlLoader:URLLoader = new URLLoader();
    var eventsData:XML = new XML();

    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest(“events.xml”));

    function LoadXML(e:Event):void {
    //some more code here
    }

    the exact error on main.swf is:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at googlemaps_fla::MainTimeline/LoadXML()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    any help is appreciated.

  76. Thank you for writing your blog! I have been struggling with a script for a few days and I kept getting a ton of errors. I finally fixed everything today by trial and error except error #1009 and after I read your solution I fixed it! Thank you!

  77. wow, thanks for the advice on this. i was getting so annoyed that i couldn’t figure it out. what i did was i made a tween on an earlier frame and instantiated a movieclip after the tween, but didn’t instantiate the movieclips on the frame before the tween when i had made the alpha to 0. thanks for the assistance!

  78. a had this type of error

    i was trying to access to an method on another Class …. and this error pops

    the problem was that i had and non existing variable in the method that i was trying to access

  79. i got this error too.. 2 days till now, me n my friend try to solve this eror…
    we move the script and the button that have listener to the same layer at the same frame..
    sometimes this is work.. i don’t know why this happen.. but not all this eror can use this method.. thats why i want know what is exactly the problem? script? or place of object?

    my chse.. i compile the main scene.. there is no problem all of script is works, but when i compile the whle fla (include the intro scene) i got this eror(#1009) and make me to decided to sleep… why this happen again?? script? or scene?
    scene intro and scene main is on the same .fla

  80. Thanks for explaining the error instead of just posting a random bit of code that won’t show the error 😉 That seems to be what the rest of the internet resources do.

    Lotsa love,
    Jerry

  81. I have been getting this TypeError: Error #1009 for several months now at various Flash sites. It seems to happen randomly and at any site that has a lot of flash content, even simple ones like yahoo (with flash ads). It doesn’t happen on any other computer I go on, so I know it isn’t the sites. I’ve tried updating Flash, updating my browser, everything I can think of to get rid of it but just can’t seem to. I’ve done lots of forum searches, and seems that people normally experience this when working with there own Flash content, which I do not do. Any help is greatly appreciated.

  82. Hi!

    I have 8 buttons in my scene and here is my action code:

    var pressed:Boolean = false;
    var xBoton:int;
    var yBoton:int;

    this.btEmpresa1.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa1.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa1.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa2.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa2.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa2.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa3.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa3.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa3.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa4.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa4.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa4.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa5.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa5.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa5.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa6.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa6.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa6.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa7.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa7.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa7.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    this.btEmpresa0.addEventListener(MouseEvent.CLICK, onMouseClick);
    this.btEmpresa0.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
    this.btEmpresa0.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);

    function onMouseOver(event:MouseEvent){
    Mouse.cursor = MouseCursor.BUTTON;
    }

    function onMouseOut(event:MouseEvent){
    Mouse.cursor = MouseCursor.ARROW;
    }

    function onMouseClick(event:MouseEvent){
    var nombreBoton:String = event.target.name;
    var frame:String = (nombreBoton.split(“bt”))[1];
    var boton:MovieClip = root[nombreBoton];
    trace(event.target.name)
    if(!pressed){
    xBoton = boton.x;
    yBoton = boton.y;
    hideDistnctButtons(nombreBoton);
    moveBoton(boton);
    gotoAndPlay(frame);
    pressed = true;
    }else{
    showDistnctButtons(nombreBoton);
    moveBackBoton(boton, xBoton, yBoton);
    gotoAndPlay(“inicio”);
    pressed = false;
    }
    }

    function moveBoton(boton:MovieClip){
    while(boton.x > 51.9){
    boton.x = boton.x – 0.01;
    }
    boton.x = 51.9;
    while(boton.y > 79.2){
    boton.y = boton.y – 0.01;
    }
    boton.y = 79.2;
    }

    function moveBackBoton(boton:MovieClip, xBoton:int, yBoton:int){
    while(boton.x < xBoton){
    boton.x = boton.x + 0.1;
    }
    boton.x = xBoton;
    while(boton.y < yBoton){
    boton.y = boton.y + 0.1;
    }
    boton.y = yBoton;

    }

    function hideDistnctButtons(nombreBoton:String){
    var aOcultar:String = nombreBoton.split(“btEmpresa”)[1];
    for(var i=0; i<8; i++){
    //trace(nombreBoton + ” ” + aOcultar + ” ” + i)
    if(i != parseInt(aOcultar)){
    (this[(“btEmpresa”+i)]).visible = false;
    }
    }

    }

    function showDistnctButtons(nombreBoton:String){
    var aOcultar:String = nombreBoton.split(“btEmpresa”)[1];
    for(var i=0; i<8; i++){
    //trace(nombreBoton + ” ” + aOcultar + ” ” + i)
    if(i != parseInt(aOcultar)){
    (this[(“btEmpresa”+i)]).visible = true
    }
    }

    }

    Some times when I press a button, I get the error: TypeError: Error #1009: Cannot access a property or method of a null object reference

    Could you help me to figure this out please?

  83. Hi im getting this error in the following, please help – its driving me nutts!

    //
    // Copyright (c) 2008, the Open Video Player authors. All rights reserved.
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions are
    // met:
    //
    // * Redistributions of source code must retain the above copyright
    // notice, this list of conditions and the following disclaimer.
    // * Redistributions in binary form must reproduce the above
    // copyright notice, this list of conditions and the following
    // disclaimer in the documentation and/or other materials provided
    // with the distribution.
    // * Neither the name of the openvideoplayer.org nor the names of its
    // contributors may be used to endorse or promote products derived
    // from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //

    // AkamaiConnection class AS3 Reference Player
    //
    // This class demonstrates use of the AkamaiConnection class
    // in connecting to the Akamai CDN and in rendering and controlling
    // a streaming video.

    package {

    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.NetStatusEvent;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.media.Video;
    import fl.controls.Button;
    import fl.controls.Slider;
    import fl.events.SliderEvent;
    import flash.external.ExternalInterface;

    import org.openvideoplayer.events.*;
    import org.openvideoplayer.net.*;

    public class accommodation extends MovieClip {

    // UI elements
    private var _video:Video;
    private var _bPlayPause:Button;
    private var _bStopVid:Button;
    private var _bFullscreen:Button;
    private var _videoSlider:Slider;
    private var _volumeSlider:Slider;
    private var _timeDisplay:TextField;
    private var _bufferingDisplay:TextField;

    // Variables
    private var _nc:AkamaiConnection;
    private var _ns:OvpNetStream;
    private var _dragging:Boolean;
    private var _streamLength:Number;

    // Constants – replace these with references to your own content
    private const HOSTNAME:String = “cp23245.edgefcs.net/ondemand”;
    private var FILENAME:String = “23245/mm/flvmedia/806/W/e/b/WebSafeAccomodation-201029?cid=806&aid=201029&afid=306727”;
    // Constructor
    public function accommodation():void {
    addChildren();
    initVars();
    }

    // Add the children to the stage
    private function addChildren():void {
    // Draw background
    this.graphics.beginFill(0x000000);
    this.graphics.drawRoundRect(0,0,898,393,0);
    this.graphics.endFill();
    // Add video
    _video = new Video(898,393);
    _video.x = 0;
    _video.y = 0;
    _video.height = 393;
    _video.width = 898;
    addChild(_video);
    // Add playPause button
    _bPlayPause = new Button();
    _bPlayPause.width = 45;
    _bPlayPause.label = “Pause”;
    _bPlayPause.enabled = false;
    _bPlayPause.x = 40;
    _bPlayPause.y = 350;
    //_bPlayPause.addEventListener(MouseEvent.CLICK,doStopVid);
    _bPlayPause.addEventListener(MouseEvent.CLICK,doPlayPause);
    addChild(_bPlayPause);
    // Add Stop button
    _bStopVid = new Button();
    _bStopVid.width = 40;
    _bStopVid.label = “Stop”;
    _bStopVid.enabled = false;
    _bStopVid.x = 90;
    _bStopVid.y = 350;
    _bStopVid.addEventListener(MouseEvent.CLICK,doStopVid);
    //_bStopVid.addEventListener(MouseEvent.CLICK,doPlayPause);
    //_bStopVid.addEventListener(MouseEvent.CLICK,doStopAnim);
    addChild(_bStopVid);
    // Add the video slider
    _videoSlider = new Slider();
    _videoSlider.width = 200;
    _videoSlider.x = 140;
    _videoSlider.y = 360;
    _videoSlider.minimum = 0;
    _videoSlider.enabled = false;
    _videoSlider.addEventListener(SliderEvent.THUMB_PRESS,beginDrag);
    _videoSlider.addEventListener(SliderEvent.THUMB_RELEASE,endDrag);
    addChild(_videoSlider);
    // Add the volume slider
    //_volumeSlider = new Slider();
    //_volumeSlider.width = 80;
    //_volumeSlider.x = 250;
    //_volumeSlider.y = 210;
    //_volumeSlider.minimum = 0;
    //_volumeSlider.maximum = 100;
    //_volumeSlider.value = 80;
    //_volumeSlider.enabled = false;
    //_volumeSlider.addEventListener(SliderEvent.CHANGE,volumeHandler);
    //addChild(_volumeSlider);
    // Add the time display
    var format:TextFormat = new TextFormat();
    format.color = 0xFFFFFF;
    format.font = “Verdana”;
    format.bold = true;
    _timeDisplay = new TextField();
    _timeDisplay.x = 240;
    _timeDisplay.y = 230;
    _timeDisplay.width = 200;
    _timeDisplay.defaultTextFormat = format;
    //addChild(_timeDisplay);
    // Add the buffering display
    _bufferingDisplay = new TextField();
    _bufferingDisplay.x = 140;
    _bufferingDisplay.y = 340;
    _bufferingDisplay.width = 200;
    _bufferingDisplay.defaultTextFormat = format;
    _bufferingDisplay.text = “Loading …”;
    addChild(_bufferingDisplay);
    }

    // Handle the start of a video scrub
    private function beginDrag(e:SliderEvent):void {
    _dragging = true;
    }

    // handle the end of a video scrub
    private function endDrag(e:SliderEvent):void {
    _ns.seek(_videoSlider.value);
    }

    // Update the volume
    private function volumeHandler(e:SliderEvent):void {
    _ns.volume = _volumeSlider.value/100;
    }

    // Handles the playPause button press
    private function doPlayPause(e:MouseEvent):void {
    switch (_bPlayPause.label) {
    case “Pause” :
    _ns.pause();
    _bPlayPause.label = “Play”;
    break;
    case “Play” :
    _ns.resume();
    _bPlayPause.label = “Pause”;
    break;
    }
    }

    // Handles the StopVid button press
    private function doStopVid(e:MouseEvent):void {
    var result:Boolean = ExternalInterface.call(‘showhide’, ‘flash’);
    _ns.pause();
    }
    //private function doStopAnim(e:MouseEvent):void {
    //var result:Boolean = ExternalInterface.call(‘zxcSlideShow’, ‘Tst,auto+’);
    //}

    // Initializes variables with starting values
    private function initVars():void {
    _dragging = false;
    _nc = new AkamaiConnection();
    _nc.addEventListener(OvpEvent.BANDWIDTH,bandwidthHandler);
    _nc.addEventListener(OvpEvent.STREAM_LENGTH,streamlengthHandler);
    _nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
    _nc.addEventListener(OvpEvent.ERROR,onError);
    _nc.connect(HOSTNAME);
    }

    // Handles a successful connection
    private function connectedHandler():void {
    trace(“Successfully connected using ” + _nc.actualProtocol + ” on port ” + _nc.actualPort);
    // As soon as we are connected, we’ll measure the available bandwidth
    _nc.detectBandwidth();

    _ns = new OvpNetStream(_nc.netConnection);

    _ns.addEventListener(OvpEvent.PROGRESS,progressHandler);
    _ns.addEventListener(OvpEvent.COMPLETE,completeHandler);
    _ns.addEventListener(NetStatusEvent.NET_STATUS,netStreamStatusHandler);
    _ns.addEventListener(OvpEvent.NETSTREAM_METADATA,metadataHandler);
    _ns.addEventListener(OvpEvent.NETSTREAM_CUEPOINT,cuepointHandler);
    }

    // Handles a successful bandwidth measurement
    private function bandwidthHandler(e:OvpEvent):void {
    trace(“The bandwidth is ” + e.data.bandwidth + “kbps and the latency is ” + e.data.latency + ” ms.”);
    // Use the bandwidth value to decide which file to play.
    if (e.data.bandwidth <= 100) {
    trace(“Selected = 100kbs : named:” + FILENAME);
    FILENAME = “23245/mm/flvmedia/806/W/e/b/WebSafeAccomodation2-201029?cid=806&aid=201029&afid=306729”;
    } else if (e.data.bandwidth <= 300){
    trace(“Selected = 300kbs : named:” + FILENAME);
    FILENAME = “23245/mm/flvmedia/806/W/e/b/WebSafeAccomodation1-201029?cid=806&aid=201029&afid=306728”;
    } else {
    trace(“Selected = 500kbs : named:” + FILENAME);
    FILENAME = “23245/mm/flvmedia/806/W/e/b/WebSafeAccomodation-201029?cid=806&aid=201029&afid=306727″;
    }

    _nc.requestStreamLength(FILENAME);
    }
    // Handles a successful stream length request
    private function streamlengthHandler(e:OvpEvent):void {
    _videoSlider.maximum = e.data.streamLength;
    _streamLength = e.data.streamLength;
    _video.attachNetStream(_ns);
    _ns.play(FILENAME);
    _bPlayPause.enabled = true;
    _bStopVid.enabled = true;
    _videoSlider.enabled = true;
    _volumeSlider.enabled = true;
    _ns.volume = .8;
    }
    // Updates the UI elements as the video plays
    private function progressHandler(e:OvpEvent):void {
    _timeDisplay.text = _ns.timeAsTimeCode + ” | ” + _nc.streamLengthAsTimeCode(_streamLength);
    if (!_dragging) {
    _videoSlider.value = _ns.time;
    }
    _bufferingDisplay.visible = _ns.isBuffering;
    _bufferingDisplay.text = “Buffering: ” + _ns.bufferPercentage+”%”;
    }

    // Handles netstream status events. We trap the buffer full event
    // in order to start updating our slider again, to prevent the
    // slider bouncing after a drag.
    private function netStreamStatusHandler(e:NetStatusEvent):void {
    switch (e.info.code) {
    case “NetStream.Buffer.Full”:
    _dragging = false;
    break;
    }
    }

    // Handles NetConnection status events. The description notifier is displayed
    // for rejection events.
    private function netStatusHandler(e:NetStatusEvent):void {
    trace(e.info.code);
    switch (e.info.code) {
    case “NetConnection.Connect.Rejected”:
    trace(“Rejected by server. Reason is “+e.info.description);
    break;
    case “NetConnection.Connect.Success”:
    connectedHandler();
    break;
    }
    }
    // Catches the end of the stream. Note that the OvpEvent.COMPLETE
    // event should only be used to detect the end of streaming files. For progressive delivery,
    // use the OvpEvent.END_OF_STREAM event.
    private function completeHandler(e:OvpEvent):void {
    _ns.pause();
    _ns.seek(0);
    _bPlayPause.label = “Play”; //changed play to stop
    _bStopVid.label = “Hide”;
    }
    // Handles metadata that is released by the stream
    private function metadataHandler(e:OvpEvent):void {
    trace(“Metadata received:”);
    for (var propName:String in e.data) {
    trace(“metadata: “+propName+” = “+e.data[propName]);
    }
    }
    // Receives all cuepoint events dispatched by the NetStream
    private function cuepointHandler(e:OvpEvent):void {
    trace(“Cuepoint received:”);
    for (var propName:String in e.data) {
    if (propName != “parameters”) {
    trace(propName+” = “+e.data[propName]);
    } else {
    trace(“parameters =”);
    if (e.data.parameters != undefined) {
    for (var paramName:String in e.data.parameters) {
    trace(” “+paramName+”: “+e.data.parameters[paramName]);
    }
    } else {
    trace(“undefined”);
    }
    }
    }
    }

    // Handles any errors dispatched by the connection class.
    private function onError(e:OvpEvent):void {
    trace(“Error: ” + e.data.errorDescription);
    }
    }
    }

  84. Thanks for this! I was getting the error ONLY when view the flash in Firefox. It didnt display it in the output window when I was working on it and didnt apear when using IE. Very weird. But including the MC in question through out and turning the opacity to 0% fixed it

  85. Hello I keep receiving this actionscript error #1009. I do not know how it got there I let my 8 year play a game on the computer and since then this error now appears. Please help me get rid of it or find out where it came from. It also makes my screen blink on and off.

  86. Hi,
    I’m getting this error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.at proces2_fla::MainTimeline/scrollPanel()

    does anyone know what I doing wrong???

    my code on scene is:

    stop();

    home_btn.addEventListener(MouseEvent.CLICK,clickHandler);
    skræd_btn.addEventListener(MouseEvent.CLICK,clickHandler1);

    filo_btn.addEventListener(MouseEvent.CLICK,clickHandler3);
    acc_btn.addEventListener(MouseEvent.CLICK,clickHandler4);
    matr_btn.addEventListener(MouseEvent.CLICK,clickHandler5);
    forand_btn.addEventListener(MouseEvent.CLICK,clickHandler6);

    function clickHandler(event:MouseEvent):void{
    navigateToURL(new URLRequest(“http://www.e41364.monline.dk/forside.html”),”_self”);
    }

    function clickHandler1(event:MouseEvent):void{
    navigateToURL(new URLRequest(“http://www.e41364.monline.dk/skraedderi.html”),”_self”);
    }

    function clickHandler3(event:MouseEvent):void{
    navigateToURL(new URLRequest(“http://www.e41364.monline.dk/filosofi.html”),”_self”);
    }

    function clickHandler4(event:MouseEvent):void{
    navigateToURL(new URLRequest(“http://www.e41364.monline.dk/accos.html”),”_self”);
    }

    function clickHandler5(event:MouseEvent):void{
    navigateToURL(new URLRequest(“http://www.e41364.monline.dk/matr.html”),”_self”);
    }

    function clickHandler6(event:MouseEvent):void{
    navigateToURL(new URLRequest(“http://www.e41364.monline.dk/foran.html”),”_self”);
    }

    panel.addEventListener(MouseEvent.MOUSE_OVER, panelOver);

    function panelOver(event:MouseEvent):void{
    panel.removeEventListener(MouseEvent.MOUSE_OVER, panelOver);
    panel.addEventListener(Event.ENTER_FRAME, scrollPanel);
    }

    var b:Rectangle = stroke.getBounds(this);

    function scrollPanel(event:Event):void{
    if(mouseX b.right || mouseY b.bottom) {
    panel.removeEventListener(Event.ENTER_FRAME, scrollPanel);
    panel.addEventListener(MouseEvent.MOUSE_OVER, panelOver);

    }

    if(panel.x >= 235) {
    panel.x = 235;
    }

    if(panel.x <= -480) {
    panel.x = -480;
    }

    var xdist = mouseX – 450;

    panel.x += -xdist / 5;
    }
    and in a movieclip I have this code:

    thum1.addEventListener(MouseEvent.CLICK,gotoSt1);

    function gotoSt1(event:MouseEvent):void{
    MovieClip(root).gotoAndStop(“St1”);
    }

    thum2.addEventListener(MouseEvent.CLICK,gotoSt2);

    function gotoSt2(event:MouseEvent):void{
    MovieClip(root).gotoAndStop(“St2”);
    }

    thum3.addEventListener(MouseEvent.CLICK,gotoSt3);

    function gotoSt3(event:MouseEvent):void{
    MovieClip(root).gotoAndStop(“St3”);
    }

    thum4.addEventListener(MouseEvent.CLICK,gotoSt4);

    function gotoSt4(event:MouseEvent):void{
    MovieClip(root).gotoAndStop(“St4”);
    }

    thum5.addEventListener(MouseEvent.CLICK,gotoSt5);

    function gotoSt5(event:MouseEvent):void{
    MovieClip(root).gotoAndStop(“St5”);
    }

  87. Thanks, Curtis!

    Your example saved me hours of pulling out my hair and rewriting my (perfectly fine) code–I just put it in the wrong spot on the timeline.

  88. i get this error when i use a code like this and go to another frame:

    addEventListener(Event.ENTER_FRAME, movingEveryFrameFunctions);

    function movingEveryFrameFunctions(event:Event):void{
    jumper();
    faller();
    movingCollisionChecker();
    mover();
    if(leftRight == 2 && allreadyIns1 == false){
    insCircle1.visible = false;
    insCircle2.visible = true;
    allreadyIns1 = true;
    }
    if(leftRight == 2 && spaceDown == true && allreadyIns2 == false){
    insCircle2.visible = false;
    insCircle3.visible = true;
    allreadyIns2 = true;
    }
    //trace(leftRight);
    }

    don’t worry all variables and such are defined elsewhere. and i figured out that the ENTER_FRAME event keeps happening and executing that function
    even while the frame is different and therefore, since the movieClips insCircle 1 through 3 don’t exist on the display list, the error comes up.

  89. Hello Curtis,

    This has been killing me for over a week. After searching the web I landed here. This is the best explanation that I’ve seen yet. But my problem seems to be compounded. Let me try to briefly explain.

    I have a simple VR, with a scroller that moves a plane back and forth. Works good. I have Nodes that animate on the plane that call out specific information about those parts. The Nodes cannot be on all the time because the Nodes intersect. Giving false links.

    This SWF is then loaded into a main file that loads up text and video depending on the clicked Node.

    I have the Scroller on the main timeline, with the Nodes and VR inside a MovieClip. I’m stuck and was hoping to find a solution that does not include going back to AS2.

    Thanks in advance.
    Garrett

  90. Oh, and if it helps at all,

    the button that’s not working gives me this error whenever I try to click on it upon export

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at MrpNewMenu_fla::MainTimeline/menuClickListen()

  91. If someone could help me out, I would be REALLY appreciative.

    I’ve been banging my head against the wall for TOO long on this.

    Essentially here’s how I’m set up.
    – On the mainstage I have a control layer (play and stop) that can control an intro audio
    – On the mainstage I also have a main movieclip for my menu.
    – Everything else is within this main movieclip (instance: MCmenu)

    – I’m externally loading all other pages (swf’s) via a load function, so that when the appropriate menu button is chosen, the proper swf is loaded into the viewing area designated on the stage.

    – I’ll include my main coding below, but ALL of my buttons work except one within menu_mc. and I’m still getting the following error that WON’T go away.

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at MrpNewMenu_fla::MCmenu_3/frame1()

    Here’s my coding for ALL of the other buttons…..

    // create a new movie clip to hold loaded content
    var contentHold:MovieClip = new MovieClip();
    addChild(contentHold);
    contentHold.x = 175;
    contentHold.y = 100;
    var swfHolder:MovieClip;

    // Loading code
    var myURLrequest:URLRequest = new URLRequest();
    var myLoader:Loader = new Loader();
    myLoader.contentLoaderInfo.addEventListener(Event.INIT, loadInitListen);
    function loadInitListen($e) {
    trace (“Loaded”);
    if (contentHold.numChildren > 0) {
    trace(“Num children ” + contentHold.numChildren);
    for (var j = 0; j < contentHold.numChildren; j++) {
    contentHold.removeChildAt(j);
    }
    }
    swfHolder = MovieClip(myLoader.content);
    contentHold.addChild(swfHolder);
    }
    // Menu code
    menu_mc.addEventListener(MouseEvent.CLICK, menuClickListen);

    function menuClickListen($e:MouseEvent):void {
    switch ($e.target) {
    //INFO FOR WOMEN SECTION
    case menu_mc.info_mc.infosub_mc.whatgs_btn:
    trace(“InfoWomen Loaded”);
    myLoader.unload();
    myURLrequest.url = “InfoWomen.swf”;
    trace(myURLrequest);
    myLoader.load(myURLrequest);
    break;
    //WOMEN AND SUBSTANCE USE SECTION
    case menu_mc.women_mc.womensub_mc.wdiff_btn:
    trace(“WomenDiff Loaded”);
    myLoader.unload();
    myURLrequest.url = “WomenandSubstances.swf”;
    trace(myURLrequest);
    myLoader.load(myURLrequest);
    break;
    /*case menu_mc.women_mc.womensub_mc.womenuse_btn:
    trace(“Why Women Use Loaded”);
    myLoader.unload();
    myURLrequest.url = “WomenandSubstances.swf”;
    myLoader.load(myURLrequest);
    break;*/
    //DIFF CATEGORIES OF DRUGS
    case menu_mc.subclass_mc.diffcat_btn:
    trace(“Diffcat Loaded”);
    myLoader.unload();
    myURLrequest.url = “SubstanceIntro.swf”;
    myLoader.load(myURLrequest);
    break;
    //STIMULANTS
    case menu_mc.subclass_mc.stim_mc.stimsub_mc.stimintro_btn:
    trace(“Stim Intro Loaded”);
    myLoader.unload();
    myURLrequest.url = “Stim.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.subclass_mc.stim_mc.stimsub_mc.cocaine_btn:
    trace(“StimBody Loaded”);
    myLoader.unload();
    myURLrequest.url = “StimBody.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.subclass_mc.stim_mc.stimsub_mc.crisk_btn:
    trace(“StimRisk Loaded”);
    myLoader.unload();
    myURLrequest.url = “StimRisk.swf”;
    myLoader.load(myURLrequest);
    break;
    //DEPRESSANTS
    case menu_mc.subclass_mc.depress_mc.depsub_mc.depintro_btn:
    trace(“Depress Intro Loaded”);
    myLoader.unload();
    myURLrequest.url = “Depress.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.subclass_mc.depress_mc.depsub_mc.heroinbody_btn:
    trace(“Depress Body Loaded”);
    myLoader.unload();
    myURLrequest.url = “DepressBody.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.subclass_mc.depress_mc.depsub_mc.heroinrisk_btn:
    trace(“Depress Risk Loaded”);
    myLoader.unload();
    myURLrequest.url = “DepressRisk.swf”;
    myLoader.load(myURLrequest);
    break;
    //HALLUCINOGENS
    case menu_mc.subclass_mc.hall_mc.hallsub_mc.hallintro_btn:
    trace(“Hall Intro Loaded”);
    myLoader.unload();
    myURLrequest.url = “HallucinIntro.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.subclass_mc.hall_mc.hallsub_mc.hallbody_btn:
    trace(“Hall Body Loaded”);
    myLoader.unload();
    myURLrequest.url = “HallucinBody.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.subclass_mc.hall_mc.hallsub_mc.hallrisk_btn:
    trace(“Hall Risk Loaded”);
    myLoader.unload();
    myURLrequest.url = “HallucinRisk.swf”;
    myLoader.load(myURLrequest);
    break;
    //PREGNANCY SECTION
    case menu_mc.pregnancy_mc.pregsub_mc.baby_btn:
    trace(“Baby Effects Loaded”);
    myLoader.unload();
    myURLrequest.url = “PregIntro.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.pregnancy_mc.pregsub_mc.fasd_btn:
    trace(“FASD Loaded”);
    myLoader.unload();
    myURLrequest.url = “Fasd.swf”;
    myLoader.load(myURLrequest);
    break;
    case menu_mc.pregnancy_mc.pregsub_mc.preghealth_btn:
    trace(“Preg Health Loaded”);
    myLoader.unload();
    myURLrequest.url = “PregHealth.swf”;
    myLoader.load(myURLrequest);
    break;
    //HEALTH PROMO SECTION
    case menu_mc.health_mc.healthsub_mc.pain_btn:
    trace(“Pain Management Loaded”);
    myLoader.unload();
    myURLrequest.url = “HealthPromo.swf”;
    myLoader.load(myURLrequest);
    break;
    }
    }
    // Playback control
    /*play_mc.addEventListener(MouseEvent.CLICK, playListen);
    function playListen($e) {
    swfHolder.play();
    }
    stop_mc.addEventListener(MouseEvent.CLICK, stopListen);
    function stopListen($e) {
    swfHolder.stop();*/

    play_mc.addEventListener(MouseEvent.CLICK, playListen);
    function playListen(event:MouseEvent):void {
    swfHolder.play();
    }
    stop_mc.addEventListener(MouseEvent.CLICK, stopListen);
    function stopListen(event:MouseEvent):void {
    swfHolder.stop();
    }

    I have no idea why this is happening and really need a solution, as I’m not that advanced in coding.

    Thanks in advance

  92. I keep getting the error whats wrong with it?

    stop();

    function goHome(e:MouseEvent):void {
    gotoAndStop(“Home”);
    }
    Home_btn.addEventListener(MouseEvent.CLICK, goHome);

    function goDivisions(e:MouseEvent):void {
    gotoAndStop(“Divisions”);
    }
    Div_btn.addEventListener(MouseEvent.CLICK, goDivisions);

    function goHistory(e:MouseEvent):void {
    gotoAndStop(“History”);
    }
    History_btn.addEventListener(MouseEvent.CLICK, goHistory);

    function goPhotos(e:MouseEvent):void {
    gotoAndStop(“Photos”);
    }
    Photos_btn.addEventListener(MouseEvent.CLICK, goPhotos);

    function goVideos(e:MouseEvent):void {
    gotoAndStop(“Videos”);
    }
    Videos_btn.addEventListener(MouseEvent.CLICK, goVideos);

    function goSponsors(e:MouseEvent):void {
    gotoAndStop(“Sponsors”);
    }
    Sponsors_btn.addEventListener(MouseEvent.CLICK, goSponsors);

    function goContact(e:MouseEvent):void {
    gotoAndStop(“Contact”);
    }
    Contact_btn.addEventListener(MouseEvent.CLICK, goContact);

    function goDesign(e:MouseEvent):void {
    gotoAndStop(“Design”);
    }
    Design_btn.addEventListener(MouseEvent.CLICK, goDesign);

    function goEngineering(e:MouseEvent):void {
    gotoAndStop(“Engineering”);
    }
    Engineering_btn.addEventListener(MouseEvent.CLICK, goEngineering);

    function goFinance(e:MouseEvent):void {
    gotoAndStop(“Finance”);
    }
    Finance_btn.addEventListener(MouseEvent.CLICK, goFinance);

    function goMarketing(e:MouseEvent):void {
    gotoAndStop(“Marketing”);
    }
    Marketing_btn.addEventListener(MouseEvent.CLICK, goMarketing);

    function goOperations(e:MouseEvent):void {
    gotoAndStop(“Operations”);
    }
    Operations_btn.addEventListener(MouseEvent.CLICK, goOperations);

    function goback(e:MouseEvent):void {
    gotoAndStop(“back”);
    }
    back_btn.addEventListener(MouseEvent.CLICK, goHome);

    Sponsors_btn.addEventListener(MouseEvent.CLICK, goSponsors);

  93. Hello Curtis J Morley,

    I still have a problem with the TypeError: Error #1009: Cannot access a property or method of a null object reference in Flash Actionscript 3. Could you please help me?

    I have several buttons,all of them on different keyframes with their own label tag (Page0, Page1, Page2, and so on). I have this code on my button in Page0 in my main time line actions layer:

    button1.addEventListener(MouseEvent.CLICK, action1);
    function action1(event:MouseEvent):void {
    //click event
    if(event.type == “click”){
    gotoAndStop(“Page1”);
    }
    }

    This button works, however: the addEventListener is not removed, it is still there when entering frame Page1! When I then try to hit button2 in frame Page1 to go to frame page2, it won’t work: the flash movie will not go to and stop at Page2, because the eventListener is still searching for button1, which is not on the stage anymore. Flash then gives me the null-object error.

    So can you please tell me how to remove the addEventListener of button1 when the button is clicked and the flash movie goes to the frame Page1?

    Thanks in advance!

    Regards, Michiel (AS3 newbie)

  94. Hi

    i have problem with #1009 error
    ———————————-
    i wtached Object-Oriented Scrollbar: Part 2 video tutorial
    http://www.gotoandlearn.com/play?id=72

    source of tutorial:
    http://gotoandlearn.com/files/oopscroll2.zip
    ———————————–
    every thing is fine
    but, when i load the swf to main.swf

    – i can scrol the scroller, but not the content
    – i got this error

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.leebrimelow.ui::ScrollBar()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at com.leebrimelow.ui::ScrollBox()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.leebrimelow.ui::ScrollBox()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()

    the scenario is:
    – the main time line play and stop at 56.
    – at 56 the main.swf loads the sec1.swf

    any help please to fix this prob
    Thanks in advance

  95. I am doing a Flash site where buttons are clicked and external SWFs load via “addChildAt (myLoader, 0)”. Each SWF that loads has on its first frame a preloader script and movie then the main content starts at frame 2. When the site loads, it loads home.swf into eec.swf (which contains navigation). No errors yet, until I load another SWF. No matter which SWF is loaded next, I get “TypeError: Error #1009: Cannot access a property or method of a null object reference. at home_fla::MainTimeline/PL_LOADING()”. My guess is this has something to do with navigation being in the parent (eec.swf) and the function being in a child (home.swf), but I can’t figure out how to fix it without breaking the loading SWF itself. Each SWF works correctly with no error by itself. Any help would be greatly appreciated.

    Here is the eec.swf frame1 script which controls navigation:
    stop();

    import flash.display.*;

    var myLoader:Loader = new Loader();
    myLoader.load(new URLRequest(“home.swf”));
    addChildAt(myLoader, 0);

    function uiButton(event:MouseEvent):void {
    //if home button is clicked
    if (event.target==home_btn) {
    if (currentLabel==”about”) {
    gotoAndStop(“home”);
    } else {
    gotoAndStop(“home”);
    removeChild(myLoader);
    myLoader.load(new URLRequest(“home.swf”));
    addChildAt(myLoader, 0);
    }
    }
    //if New Construction button is clicked
    if (event.target==newConstr_btn) {
    if (currentLabel==”about”) {
    gotoAndStop(“home”);
    myLoader.load(new URLRequest(“newConstr.swf”));
    addChildAt(myLoader, 1);
    } else {
    removeChild(myLoader);
    myLoader.load(new URLRequest(“newConstr.swf”));
    addChildAt(myLoader, 1);
    }
    }
    //if Remodeling button is clicked
    if (event.target==remodel_btn) {
    if (currentLabel==”about”) {
    gotoAndStop(“home”);
    myLoader.load(new URLRequest(“remodel.swf”));
    addChildAt(myLoader, 1);
    } else {
    removeChild(myLoader);
    myLoader.load(new URLRequest(“remodel.swf”));
    addChildAt(myLoader, 1);
    }
    }
    //if Custom Builds button is clicked
    if (event.target==custom_btn) {
    if (currentLabel==”about”) {
    gotoAndStop(“home”);
    myLoader.load(new URLRequest(“custom.swf”));
    addChildAt(myLoader, 1);
    } else {
    removeChild(myLoader);
    myLoader.load(new URLRequest(“custom.swf”));
    addChildAt(myLoader, 1);
    }
    }
    //if About button is clicked
    if (event.target==about_btn) {
    removeChild(myLoader);
    gotoAndPlay(“about”);
    }
    }

    home_btn.addEventListener(MouseEvent.CLICK,uiButton);
    newConstr_btn.addEventListener(MouseEvent.CLICK,uiButton);
    remodel_btn.addEventListener(MouseEvent.CLICK,uiButton);
    custom_btn.addEventListener(MouseEvent.CLICK,uiButton);
    about_btn.addEventListener(MouseEvent.CLICK,uiButton);

    Here is the frame 1 preloader script that is each SWF that is loaded:
    stop();

    import flash.display.*;
    this.stop();

    this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);

    function PL_LOADING(event:ProgressEvent):void {
    var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
    bar_mc.scaleX=pcent/100;
    loading_txt.text=”Loading – ” +int(pcent)+”%”;

    if(pcent==100){
    this.gotoAndPlay(2);
    }
    }

  96. i am brand new to flash so pardon me if this is retarded. im trying to make a button which has a movieclip as its mouseover function work as a link to an external site. no matter what i do to the code the button remains non-functional and i get the 1009 error. please help

    pure.addEventListener(MouseEvent.CLICK, pureitem)
    function pureitem (evt) {
    var url = “http://myweb.com/”
    navigateToURL(new URLRequest(url))
    }
    stop();

  97. Ok, this should be EZ but I cant get it. i have a function that displays an image when a certain object is clicked. I want to remove the previous image when the next object is clicked but i cant seem to access it outside of the block that its in, as shown by the 2 trace methods… I just get the lovely ERROR#1009 on the trace outside of the if statement

    function dispMain(bookInput:XML, curn:int):void {

    if (swh1 == 0) {
    var loader:Loader = new Loader();
    var loaderMain:MovieClip = new MovieClip();
    loaderMain.mouseChildren = false;

    loaderMain.addChild(loader);
    this.addChild(loaderMain);
    loaderMain.name = “loadmain”;

    var loader2:Loader = new Loader();
    var loadMask:MovieClip = new MovieClip();
    loadMask.mouseChildren = false;
    loadMask.addChild(loader2);
    this.addChild(loadMask);
    loadMask.name = “stageMask”;
    loader2.load(new URLRequest(“http://www.squisheesoft.com/images/clearfix.png”));
    loadMask.x = 20;
    loadMask.y = 100;
    loadMask.scaleX = 60;
    loadMask.scaleY = 100;
    loaderMain.mask = loadMask;

    loader.load(new URLRequest(bookInput.Book.imageLG.text()[curn]));
    loaderMain.x = 30;
    loaderMain.y = 50;
    loaderMain.scaleX = .5;
    loaderMain.scaleY = .5;
    //trace(curn);

    loaderMain.addEventListener(MouseEvent.MOUSE_DOWN, mainDrag);
    loaderMain.addEventListener(MouseEvent.MOUSE_UP, stopDr);
    loaderMain.addEventListener(MouseEvent.MOUSE_OUT, stopDr);
    trace (loaderMain.name);
    swh1 = 1;
    return;
    }

    swh1 = 0;
    trace (loaderMain.name);

    }

    if you need the complete code, let me know

  98. Help! I’m being held hostage by error 1009!

    Here’s the problem. I have a program I’m trying to make for AIR with flash. So far, it is only a basic text editor. Here’s my code:

    import flash.filesystem.*

    stop();
    var defaultDirectory:File = File.documentsDirectory;
    var stream:FileStream;
    var currentFile:File;
    openBTN.addEventListener(MouseEvent.CLICK, openFileFunction)
    saveBTN.addEventListener(MouseEvent.CLICK, saveFileFunction)
    saveAsBTN.addEventListener(MouseEvent.CLICK, saveAsFileFunction)

    function openFileFunction(event:MouseEvent):void {
    openFile(defaultDirectory)
    }
    function openFile(root:File){
    var TXTFilter:FileFilter = new FileFilter(“Text (*.txt,*.htm,*.html)”,”*.txt;*.htm;*.html”)
    root.browseForOpen(“Open”, [TXTFilter])
    root.addEventListener(Event.SELECT, openFileSelected)
    }
    function openFileSelected(event:Event):void {
    stream = new FileStream;
    currentFile = defaultDirectory
    stream.openAsync((currentFile as File), FileMode.READ)
    stream.addEventListener(Event.COMPLETE, fileReadHandler)
    }
    function fileReadHandler(event:Event):void {
    var txt:String = stream.readUTFBytes(stream.bytesAvailable);
    stream.close();
    MainTXT.text = txt
    }
    function saveFileFunction(event:MouseEvent){
    saveFile()
    }
    function saveFile(){
    if (currentFile){
    if (stream != null){
    stream.close()
    }
    stream.open(currentFile, FileMode.WRITE);
    var txt:String = MainTXT.text
    stream.writeUTFBytes(txt)
    stream.close()
    } else {
    saveFileAs(defaultDirectory)
    }
    }
    //*******************************************************************
    //SaveAs
    function saveAsFileFunction(event:MouseEvent){
    saveFileAs(defaultDirectory)
    }
    function saveFileAs(root:File){
    root.browseForSave(“Save As”)
    root.addEventListener(Event.SELECT, saveAsFileSelected)
    }
    function saveAsFileSelected(event:Event):void{
    currentFile = defaultDirectory
    saveFile()
    }

    I have openBTN, saveBTN, and saveAsBTN on the stage. Also, it says my error is on line 41. This is inside the saveFile() function, on this line:

    stream.open(currentFile, FileMode.WRITE)

    What is wrong?

  99. Well, you can try two things…

    a) It’s better to just assign an event that fires when the new SWF is finished loading… (instead of the OnEnter way)

    ex.
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompletedFunction);

    B) And try accessing your newly loaded variables like this…

    localVar = MovieClip(myLoader.content).someVar;

    The MovieClip() wrapper apparently is required here, or things get screwed up.

    Good luck!

  100. I get this error and I can’t figure it out. I am new to actionscript so please help me out. Here is my code:

    import flash.events.MouseEvent;
    import flash.display.MovieClip;

    servicesbtn.addEventListener(MouseEvent.MOUSE_OVER,services);
    function services(MouseEvent):void {
    gotoAndStop(2);
    }

    servicesmask.addEventListener(MouseEvent.MOUSE_OVER,servgone);
    function servgone(MouseEvent):void {
    gotoAndStop(1);
    }

  101. Hello. I get this error but just if i’m dowloading the swf from a web server or I’m simulating the download in the authoring mode. I’ve got an onEnterFrame function and in the very earlier cycles it seems not able to find the .text property of a textfield wich is inside a movieclip attached from the libraryusing addChild(). I’m also sure that the addChild method is called before the onEnterFrame function starts. Any ideas? And, by the way, the error I see in my browser can be seen by anyone or just by developers? Thank you.

  102. Making a flash As3 form that takes the info entered and puts it into a mysql database by using php.

    — the code —
    stop();

    usrPassword.displayAsPassword = true;

    registerBtn.addEventListener(MouseEvent.CLICK, sdClicked);
    function sdClicked(e:MouseEvent):void {
    if (usrFName.text!=”” && usrLName.text!=”” && usrLogin.text!=”” && usrPassword.text!=””) {
    var myData:URLRequest = new URLRequest(“mysite.php”);
    myData.method = URLRequestMethod.POST;
    var variables:URLVariables = new URLVariables;
    variables.usrFName = usrFName.text;
    variables.usrLName = usrLName.text;
    variables.usrLogin = usrLogin.text;
    variables.usrPassword = usrPassword.text;
    myData.data = variables;
    var loader:URLLoader = new URLLoader();
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    function dataOnLoad(evt:Event) {
    trace(evt.target.data.writing);
    if(evt.target.data.writing==”Ok”) {
    gotoAndStop(2);
    } else {
    status_txt.text = “Error in saving submitted data”;
    }
    }
    loader.addEventListener(Event.COMPLETE, dataOnLoad);
    loader.load(myData);
    } else {
    status_txt.text = “All fields are mandatory”;
    }
    }

    — the error —
    Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables()
    at flash.net::URLLoader/onComplete()

    So what the crap is wrong?

    I am almost ready to throw flash in the toliet and go back to the basics and use striaght php.

    any help is greatly needed

  103. Hi Curtis,
    I making a game in Flash CS3. I keep getting this error. Here’s the error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.at my_algebra_map_11_24_fla::MainTimeline/checkDoors()

    and here is the function checkDoors:

    function checkDoors(event:Event):void {

    var doors:Array = new Array();
    doors=[map.door1, map.door2, map.door3, map.door4];

    if(character.hitTestObject(map.door1)) {
    gotoAndStop(5);
    }

    if(character.hitTestObject(map.door2)) {
    gotoAndStop(5);
    }

    }

    I am lost as to how the code isn’t finding door1 and door2.
    Any suggestions would be great!
    thanks for the wonderful site,
    Scott

  104. Hi Curtis,

    Heeelp! I’m getting the dreaded 1009! 🙂 I’m trying to preload my main movie swf externally which has a doc class. The doc class controls a particle effect (the one we made in class) but it gives me the 1009 when it loads. If I comment out the particles “for” loop in the doc class I don’t get the error. I think it has something to do with the “stage” being passed into the ParticleLogo() function but I’m stumped. Is there a better way to do this then what I have below?

    DOC CLASS CODE:
    package
    {
    import flash.display.MovieClip;

    public class Bohmanart extends MovieClip
    {
    public function Bohmanart():void
    {
    init();
    trace(“doc class loaded”);
    }
    private function init():void
    {
    for (var i:uint = 0; i < 19; i++)
    {
    var myNewLogo:ParticleLogo = new ParticleLogo(stage);
    myNewLogo.x = Math.random()*(stage.stageWidth-myNewLogo.width)+myNewLogo.width/2;
    myNewLogo.y = Math.random()*(stage.stageHeight-myNewLogo.height)+myNewLogo.height/2;
    myNewLogo.cacheAsBitmap = true;
    addChildAt(myNewLogo, 0);
    }
    }
    }
    }

    PRELOADER CODE:
    var bohmanart:Loader = new Loader();
    var req:URLRequest = new URLRequest(“bohmanart.swf”)

    bohmanart.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, prog);
    bohmanart.contentLoaderInfo.addEventListener(Event.COMPLETE, fin);
    bohmanart.load(req);

    function prog(e:ProgressEvent):void
    {
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    }

    function fin(e:Event):void
    {
    removeChildAt(0);
    addChild(bohmanart);
    }

  105. Howdy, getting the error in question and stuck.
    Have a map style nav setup to scroll to different sections of a large movieclip and getting the error.
    I have the mc’s that I’m trying to pull in set with the linkage on. Should I still have them on the stage with an alpha of 0 or something. Many Thanks:

    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;

    var homeX:Number = 500;
    var homeY:Number = 375;

    var aboutX:Number = 1024.0;
    var aboutY:Number = 768;

    var mediaX:Number = -24;
    var mediaY:Number = 768;

    var newsX:Number = 1024.0;
    var newsY:Number = -18;

    var contactX:Number = 24;
    var contactY:Number = 28;

    var xTween:Tween;
    var yTween:Tween;
    var inTween:Tween;
    var outTween:Tween;

    xTween = new Tween(main_mc,”x”, Strong.easeInOut,main_mc.x,homeX,2,true);
    yTween = new Tween(main_mc,”y”, Strong.easeInOut,main_mc.y,homeY,2,true);

    inTween = new Tween(main_mc.home_mc, “alpha”, None.easeNone, 0,1,.5,true);
    outTween = new Tween(main_mc.home_mc, “alpha”, None.easeNone, 1,0,.5,true);

    xTween.addEventListener(TweenEvent.MOTION_FINISH,fadeIn);
    xTween.addEventListener(TweenEvent.MOTION_START,fadeOut);

    home_btn.addEventListener(MouseEvent.CLICK, navigate);
    about_btn.addEventListener(MouseEvent.CLICK, navigate);
    media_btn.addEventListener(MouseEvent.CLICK, navigate);
    news_btn.addEventListener(MouseEvent.CLICK, navigate);
    contact_btn.addEventListener(MouseEvent.CLICK, navigate);

    function navigate(event:MouseEvent):void
    {
    if(event.target == about_btn)
    {
    setTween(aboutX,aboutY,main_mc.about_mc);
    }
    else if(event.target == media_btn)
    {
    setTween(mediaX,mediaY,main_mc.media_mc);
    }
    else if(event.target == news_btn)
    {
    setTween(newsX,newsY,main_mc.news_mc);
    }
    else if(event.target == contact_btn)
    {
    setTween(contactX,contactY,main_mc.contact_mc);
    }
    else
    {
    setTween(homeX,homeY,main_mc.home_mc);
    }
    }

    function setTween(tweenX:Number,tweenY:Number, tweenMC:MovieClip):void
    {
    xTween.begin = main_mc.x;
    yTween.begin = main_mc.y;
    xTween.finish = tweenX;
    yTween.finish = tweenY;
    tweenMC.alpha = 0;
    inTween.obj = tweenMC;
    xTween.start();
    yTween.start();
    }

    function fadeIn(event:TweenEvent):void
    {
    inTween.start();
    outTween.obj = inTween.obj;
    }
    function fadeOut(event:TweenEvent):void
    {
    outTween.start();
    }

    xTween.stop();
    yTween.stop();
    inTween.stop();
    outTween.stop();

  106. I have to use scenes for my project. I am getting this error code to.

    My button to contacts works. but once it gets there is when i get the error code. here is my code

    stop();
    btnHome.addEventListener(MouseEvent.CLICK, goHome);
    btnContact.addEventListener(MouseEvent.CLICK, goContact);
    btnServices.addEventListener(MouseEvent.CLICK, goServices);
    function goHome(event:MouseEvent):void {
    gotoAndStop(203, “Scene 1”);
    }
    function goContact(event:MouseEvent):void {
    gotoAndPlay(1, “Scene 2”);
    }
    function goServices(event:MouseEvent):void {
    gotoAndStop(1, “Scene 3”);
    }

  107. I figured it out. my guess, the preloader prevented the object from initializing, and by moving Download_Interface.disable(); to the frame after the preloader, made everything work. Weird…

  108. I’m having a problem with an download progress bar I have made. All of the instance names are unique, the layers are unique, the symbols are unique. The symbol seems to referenece the classes just fine. The problem is that I get this error, after I have initialized the symbol on the stage. The next command it recieves is to toggle the visibility of the download progress bar, which it carries out, but throws this type error 1009. This would not be a problem except that it will also throw the error on the webpage with CS4.
    I’m still waiting on content for my site from my boss; however, the prototype functions except for this one Type Error.
    I’ve been searching for answer a better part of two days now, any ideas?

    The instance is named Download_Interface
    the parent symbol is downloader_interface;

    Frame 1

    import com.ProjectControls.[ProjectControls;
    import com.ProjectControls.Downloader.Downloader;

    var Download_Interface:Downloader;

    Download_Interface.disable();

    var loaded:Number;
    var total:Number;

    var bar_mc:MovieClip = new MovieClip;
    var loader_txt:TextField = new TextField;

    this.addEventListener(Event.ENTER_FRAME, loading);

    stop();
    function loading(e:Event):void{

    total = this.stage.loaderInfo.bytesTotal;
    loaded = this.stage.loaderInfo.bytesLoaded;

    bar_mc.scaleX = loaded/total;
    loader_txt.text = “Loading: ” + Math.floor((loaded/total)*100)+ “%”+ ” Complete”;

    if (total == loaded)
    {
    play();
    this.removeEventListener(Event.ENTER_FRAME, loading);
    }
    }

    ProjectControls.as
    package com.ProjectControls
    {
    import flash.net.*;
    import flash.events.*;
    import flash.display.*;
    import flash.text.*;
    import com.ProjectControls.Downloader.Downloader;

    public class ProjectControls extends MovieClip
    {

    }
    }

    package com.ProjectControls.Downloader
    {
    import flash.net.*;
    import flash.events.*;
    import flash.display.*;
    import flash.display.MovieClip;
    import flash.text.*;
    import flash.utils.*;
    import com.ProjectControls.ProjectControls;

    public class Downloader extends ProjectControls
    {
    public var progressTXT:TextField;
    public var progress_MC:MovieClip;
    public var encasement_MC:MovieClip;
    public var cancelBTN:SimpleButton;
    public var insertedMyFileReference:FileReference = new FileReference;
    public var myrequest:URLRequest;
    public var TotalByteSize:Number;
    public var DownloadedByteSize:Number;

    public function disable():void
    {
    encasement_MC.visible = false;
    progress_MC.visible = false;
    progressTXT.text = ” “;
    cancelBTN.visible = false;
    }
    public function downloadEvent(MyFileReference, myrequest):void
    { enableInterface();
    insertedMyFileReference = MyFileReference;
    insertedMyFileReference.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    insertedMyFileReference.addEventListener(Event.COMPLETE, completeHandler);
    insertedMyFileReference.download(myrequest);
    }
    public function enableInterface():void
    {
    cancelBTN.visible = true;
    progressTXT.visible = true;
    progressTXT.text = “PREPARING DOWNLOAD”;
    cancelBTN.enabled = true;
    progress_MC.visible = true;
    encasement_MC.visible = true;
    cancelBTN.addEventListener(MouseEvent.CLICK, CancelDownload);
    }
    /**
    * While the file is downloading, update the progress bar’s status. it’s only text, gotta turn text into visual aid
    **/
    public function progressHandler(event:ProgressEvent):void
    {
    /*scale a bar via math of bytesloaded/bytestotal*/
    TotalByteSize = event.bytesTotal;
    DownloadedByteSize = event.bytesLoaded;
    progress_MC.scaleX = DownloadedByteSize/TotalByteSize;
    progressTXT.text = “Downloading: ” + Math.floor((DownloadedByteSize/TotalByteSize)*100)+ “%”+ ” Complete”;
    }

    public function completeHandler(event:Event):void
    {
    var timer = new Timer(5000,1);
    timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
    timer.start();
    progressTXT.text = “DOWNLOAD COMPLETE”
    cancelBTN.enabled = false;
    function onTimerComplete(event:TimerEvent):void
    {
    progressTXT.visible = false;
    cancelBTN.enabled = false;
    cancelBTN.visible = false;
    encasement_MC.visible = false;
    progress_MC.visible = false;
    }
    }
    public function CancelDownload(event:MouseEvent):void
    {
    insertedMyFileReference.cancel();
    var timer = new Timer(5000,1);
    progressTXT.text = “DOWNLOAD CANCELLED”;
    timer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
    timer.start();
    function onTimerComplete(event:TimerEvent):void
    {
    progressTXT.visible = false;
    cancelBTN.enabled = false;
    cancelBTN.visible = false;
    encasement_MC.visible = false;
    progress_MC.visible = false;
    }
    }

    }
    }

  109. Hi am getting the following error :

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at fl.video::CuePointManager/dispatchASCuePoints()
    at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::doUpdateTime()
    at flash.utils::Timer/flash.utils:Timer::_timerDispatch()
    at flash.utils::Timer/flash.utils:Timer::tick()

    And below is my code :

    package
    {
    import fl.video.FLVPlayback;
    import fl.video.MetadataEvent;
    import fl.video.CuePointType;
    import fl.video.VideoEvent;
    import flash.display.Sprite;

    public class CuePointsTest1 extends Sprite {

    private var videoPath:String = “rtmp://16.138.201.138/teststream/water.flv”;
    private var cuePt:Object = new Object(); // create cue point object

    public function CuePointsTest1() {
    trace(‘inside constructor’);
    cuePt.time = 1;
    cuePt.name = “ASCuePt1”;
    cuePt.type = “actionscript”;
    vDO.source = “rtmp://16.138.201.138/teststream/water.flv”;
    vDO.skin = “SkinUnderAll.swf”;
    vDO.skinBackgroundColor = 0x666666;
    vDO.skinBackgroundAlpha = 0.5;
    vDO.addASCuePoint(cuePt); //add AS cue point
    vDO.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

    }

    private function cp_listener(eventObject:MetadataEvent):void{
    trace(‘cue point occured’);
    vDO.stop();
    trace(‘after Stop’);
    vDO.removeEventListener(MetadataEvent.CUE_POINT, cp_listener);
    vDO.source = “rtmp://16.138.201.138/teststream/clouds.flv”;
    trace(‘after source’);
    vDO.removeASCuePoint(cuePt);
    //vDO.play();
    trace(‘after play’);
    vDO.addEventListener(VideoEvent.COMPLETE,onComp);

    }

    private function onComp(eventObject:VideoEvent):void{
    trace(‘Inside onComp’);
    vDO.removeEventListener(VideoEvent.COMPLETE,onComp);
    vDO.source = “rtmp://16.138.201.138/teststream/water.flv”;
    vDO.seekSeconds(2);
    vDO.play();

    }

    }
    }

    am new to ActionScript.

    Please help me to solve this error.

    with thanx and regards,
    Saravanakumar

  110. Hello:
    I am getting the same error: Error #1009: Cannot access a property or method of a null object reference. at FtScrollBar/checkSize() at FtScrollBar/LwJIyBI91212G2rSD7M351()

    I am using a scrollbar component downloaded from Flashden.net
    the weird thing is at first when movie is tested, button is clicked to access scene 3 which where I am having the problem it works perfect when sub buttons are selected, but if i go back after clicking other buttons to the previous then is when I get the error and scroll bar does not work.

    Here is my actions script for all my buttons:
    sinopsis_btn1.addEventListener(MouseEvent.MOUSE_DOWN, sinopsis_2Handler);
    function sinopsis_2Handler(event:MouseEvent):void {

    gotoAndPlay(1, “Scene 1”);

    }

    elenco_btn.addEventListener(MouseEvent.MOUSE_DOWN, elenco_2Handler);
    function elenco_2Handler(event:MouseEvent):void {

    gotoAndPlay(1, “Scene 2”);

    }

    edmundo_btn.addEventListener(MouseEvent.MOUSE_DOWN, edmundo_1Handler);
    function edmundo_1Handler(event:MouseEvent):void {

    gotoAndPlay(3, “Scene 3”);

    }

    luis_btn.addEventListener(MouseEvent.MOUSE_DOWN, luis_1Handler);
    function luis_1Handler(event:MouseEvent):void {

    gotoAndPlay(1, “Scene 3”);

    }
    stop();
    mayra_btn.addEventListener(MouseEvent.MOUSE_DOWN, mayra_1Handler);
    function mayra_1Handler(event:MouseEvent):void {

    gotoAndPlay(4, “Scene 3”);

    }

    eric_btn.addEventListener(MouseEvent.MOUSE_DOWN, eric_1Handler);
    function eric_1Handler(event:MouseEvent):void {

    gotoAndPlay(5, “Scene 3”);

    }

    ivan_btn.addEventListener(MouseEvent.MOUSE_DOWN, ivan_1Handler);
    function ivan_1Handler(event:MouseEvent):void {

    gotoAndPlay(6, “Scene 3”);

    }

    jadit_btn.addEventListener(MouseEvent.MOUSE_DOWN, jadit_1Handler);
    function jadit_1Handler(event:MouseEvent):void {

    gotoAndPlay(7, “Scene 3”);

    }

    agustin_btn.addEventListener(MouseEvent.MOUSE_DOWN, agustin_1Handler);
    function agustin_1Handler(event:MouseEvent):void {

    gotoAndPlay(8, “Scene 3”);

    }

    sophie_btn.addEventListener(MouseEvent.MOUSE_DOWN, sophie_1Handler);
    function sophie_1Handler(event:MouseEvent):void {

    gotoAndPlay(9, “Scene 3”);

    }

    carola_btn.addEventListener(MouseEvent.MOUSE_DOWN, carola_1Handler);
    function carola_1Handler(event:MouseEvent):void {

    gotoAndPlay(10, “Scene 3”);

    }

  111. Jabrat,

    I see what you mean. The second trace comes back as null. This has an easy explanation for it. If you notice the second trace is output before the first trace. This is because the second trace executes before the Event.COMPLETE triggers.

    So it is not resetting. The function is waiting for “loader” to get data where the trace that is not inside the function doesn’t wait and therefore you get the trace output before the data has arrived.

    The data is there and it is accessible in frame 2 also as long as you have waited for the “loader” to get the data first. If this the only code in frame 1 and you try and access the “items” in frame 2 then it will not have been received yet and therefore Error 1009.

    Try replacing your function with this code:

    function onLoadComplete( event:Event ):void
    {
    if ( loader.data )
    {
    list = XML( loader.data );
    items = list.item;
    nextFrame();
    }
    trace( list );
    }

    stop();

  112. var list:XML;
    var items:XMLList;
    var listPos:Number = 0;
    var url:URLRequest = new URLRequest( “http://www.ccchuntersville.com/new/includes/getBannerAds.php” );
    var loader:URLLoader = new URLLoader();
    loader.addEventListener( Event.COMPLETE, onLoadComplete );
    loader.load( url );

    function onLoadComplete( event:Event ):void {
    if( loader.data ) {
    list = XML( loader.data );
    items = list.item;
    }

    trace( list );
    }

    trace( list );

    The first trace works fine, but the second does not. As soon as the function is exited it seems to reset list, why? Is there some scope problem I’m just not seeing. On the next frame I’m trying to access items but I get the 1009 error.

  113. Hello all! So, I’ve got an Error #1009 issue and would love a little guidance. On the first frame of my timeline, I have preloader animation that tracks the progress of the download. On the last frame of my timeline, I have a movie clip called INTRO_anim that loads after all of the content for my website. What I would like to be able to do is skip to the next frame of the timeline (which is where all the content is) once it’s ready and forget about playing the intro if I choose to do so. When I launch my swf and click on SKIP_btn, a bunch of 1009’s pop up along with some 1010’s. Here’s my code:

    stop();

    SKIP_btn.gotoAndStop(4);
    START_btn.gotoAndStop(2);

    SKIP_btn.buttonMode = true;
    START_btn.buttonMode = true;

    this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
    this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

    function onProgress (event:ProgressEvent): void {
    var loaded:Number = event.target.bytesLoaded;
    var total:Number = event.target.bytesTotal;
    var pct:Number = loaded/total;
    LOADING_anim.gotoAndStop(Math.round(pct*100));
    loaded_txt.text = “Loading Site… ” + (Math.round(pct*100)) + “%”;
    if(framesLoaded >= 22) {
    SKIP_btn.gotoAndStop(1);
    SKIP_btn.addEventListener(MouseEvent.MOUSE_DOWN, SKIP_early_down);
    SKIP_btn.addEventListener(MouseEvent.MOUSE_OVER, SKIP_early_over);
    SKIP_btn.addEventListener(MouseEvent.MOUSE_OUT, SKIP_early_out);
    loaded_txt.text = “Loading Intro…” + + (Math.round(pct*100)) + “%”;
    function SKIP_early_down (event:MouseEvent): void {
    this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
    nextFrame();
    }
    function SKIP_early_over (event:MouseEvent): void {
    SKIP_btn.gotoAndStop(2);
    }
    function SKIP_early_out (event:MouseEvent): void {
    SKIP_btn.gotoAndStop(1);
    }
    }

    if(pct == 1) {
    loaded_txt.text = “”;
    }
    }
    function onComplete (event:Event): void {
    SKIP_btn.gotoAndStop(1);
    SKIP_btn.addEventListener(MouseEvent.MOUSE_DOWN, SKIP_down);
    SKIP_btn.addEventListener(MouseEvent.MOUSE_OVER, SKIP_over);
    SKIP_btn.addEventListener(MouseEvent.MOUSE_OUT, SKIP_out);

    function SKIP_down (event:MouseEvent): void {
    SKIP_btn.gotoAndStop(3);
    nextFrame();
    }
    function SKIP_over (event:MouseEvent): void {
    SKIP_btn.gotoAndStop(2)
    }
    function SKIP_out (event:MouseEvent): void {
    SKIP_btn.gotoAndStop(1)
    }
    }

    Any ideas? Thanks a lot for any help.

  114. Elksie,

    There are 2 things happening here that are giving you the error. The first is that you have a MOUSE_DOWN event that does a gotoAndStop(“Name”); and you also have a MOUSE_OUT event that changes the alpha. The MOUSE_DOWN happens while the object is still there. The MOUSE_OUT happens because you are no longer in the frame with that button.

    So the MOUSE_OUT is trying to happen on an object that is no longer accessible to Flash because it is no longer on the timeline.

    To fix this you can either just set a variable and then when you come back to the frame you can reset the alpha based off of that variable or you can change the event from a MOUSE_OUT to a MOUSE_UP like so

    profilesMC.fence.kenBettany.addEventListener(MouseEvent.MOUSE_UP, mouseUpkenBettany);

    Hope this helps and happy Flashing.
    Curtis J. Morley

  115. I came across Error #1009

    while trying to build a remembrance flash package.

    Essentially, I’m trying to recreate something I’ve seen on the MediaStorm website http://mediastorm.org/0024.htm a scrolling banner of images, each of which acts like a button to click through to a video player that I’ve managed to find.

    But I’ve hit a problem with the error which is driving me mad.

    The URL for the package is:
    http://i.thisis.co.uk/274136/binaries/Remembrance9.fla

  116. I came across Error #1009 in a big FLA:
    I testet accesssing nested MovieClips and tell them something (e.g. gotoAndPlay). It’s no problem in my little test FLA. But in my project with long timelines, sounds and graphics, it just won’t work!!!
    The FLA is is here:
    http://www.id.uzh.ch/mels/projekte/zrm/rudi_test.fla
    If you run it, you will see the rror and it will bring you to the code I’m talking about.
    I have tried sooo many things, just nothing seems to work. Any suggestions?

  117. i’m just curious, it’s an unrelated problem actually, but

    i have a button that is actionscripted to play a movieclip. the thing is, the first frame of that movieclip has a stop(); command in it.

    so my question is, will it play? which script takes higher priority? and if not, is there any way around this?

  118. I keep on getting Error #1009 when I am on Facebook and playing Scrabble.
    I press Dismiss all and the games disappear, so I press Continue and the same thing happens! Help!

  119. Hello Mr. Morley,

    I have a problem with the dreaded TypeError: Error #1009: Cannot access a property or method of a null object reference. I’m creating a flash website and I have the design layout already in flash. My movieclip buttons are not taking the playhead to the specified frame label. Here is the actionscript 3.0 code for just the portfolio movieclip button:

    main_PORTFOLIO_button.buttonMode = true;

    main_PORTFOLIO_button.addEventListener(MouseEvent.ROLL_OVER, portfolioOver);
    main_PORTFOLIO_button.addEventListener(MouseEvent.ROLL_OUT, portfolioOut);
    main_PORTFOLIO_button.addEventListener(MouseEvent.CLICK, portfolioClick);

    function portfolioOver(event:MouseEvent):void
    {
    main_PORTFOLIO_button.main_PORTFOLIO_Animation.gotoAndPlay(“over”);
    }
    function portfolioOut(event:MouseEvent):void
    {
    main_PORTFOLIO_button.main_PORTFOLIO_Animation.gotoAndPlay(“out”);
    }
    function portfolioClick(event:MouseEvent):void
    {
    trace(“Clicked”);
    gotoAndPlay(“portfolio”);
    }

    The frame label “portfolio” is on the main timeline. I want this movieclip button to go to the frame label “portfolio.” The problem comes about when I click the portfolio button to go the “portfolio” frame label. It goes to the specified frame label and outputs this error message:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at Main3_fla::MainTimeline/portfolioOut()

    If you can take a look at this I would really appreciate it.

    Thanks.

  120. Jeff,

    Thanks for this great suggestion. One other thing that you can do is to listen for the COMPLETE event to fire and then assign the appropriate actions. Thanks for the compliments also. It is people like you that make writing like this worthwhile.

    Thanks and Happy Flashing,
    Curtis J. Morley

  121. Hey,
    I like your site. It is my first stop for understanding actionscript errors.
    Regarding error 1009, I found that when loading external movie clips there is a problem with the timing of items being instantiated. A movie clip that worked fine on its own gave me this error when I loaded it into another swf.
    My solution was to start a timer and run the offending function after a second or so… not that elegant but it works.

    Here is an example of the timer:

    public function addListenersTimer():void
    {
    var myTimer:Timer = new Timer(1000, 1);
    myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, addListeners);
    myTimer.start();
    }

    private function addListeners(e:TimerEvent):void
    {
    _dragger.addEventListener(MouseEvent.MOUSE_DOWN, onDraggerPress, false, 0, true);
    _dragger.addEventListener(MouseEvent.MOUSE_UP, onDraggerUp, true, 0, true);
    _dragger.stage.addEventListener(MouseEvent.MOUSE_UP, onDraggerUp, false, 0, true);
    }

    Thanks again,

    Jeff

  122. There are times where I’ve set up listeners in the Class Constructor for objects that live directly on the stage which works fine, but have to slightly rework the Class to add them dynamically, as the listener in the Constructor is simply beating the object to the stage – therefore returning a null. I add an init() function and place my original listeners there, and add a listener to the constructor that fires when the object is actually available:

    xPackage{

    YClass extends Whatever{

    public function YClass():void{
    addEventListener(Event.ADDED_TO_STAGE, init);
    }

    private function init():void{
    someObject.addEventListener(MouseEvent.MOUSE_DOWN, someFunction);
    }
    }
    }
    Hopes this helps some of you – it sure helped me.

  123. Can anyone help me? I am very green at this and am just trying to do a simple, simple, simple flash site but I cannot get around this 1009 bug. It’s awful and stopping me from getting anywhere.

    Basically how do you get the program to recognize the button as not null. I guess I mean how do you get it to read the button then apply the Action script in the proper order or vice versa whcih ever is correct. I can’t believe Adobe designed this flaw into the program. Horrible! And when i say simple I mean I don’t understand hardly any of the code above. I’m really depressed over this- ruining my efforts t get a site up- i’d made such good progress til now. Any help would be sooooo appreciated.
    The code I am using is below:

    stop();

    FsAs.addEventListener(MouseEvent.CLICK, FestsAwards);
    function FestsAwards(event:MouseEvent):void {
    gotoAndPlay(4)
    }

    CsBs.addEventListener(MouseEvent.CLICK, ContsBios);
    function ContsBios(event:MouseEvent):void {
    gotoAndPlay(35)
    }

    Imgs.addEventListener(MouseEvent.CLICK, Images);
    function Images(event:MouseEvent):void {
    gotoAndPlay(61)
    }

    CstCrw.addEventListener(MouseEvent.CLICK, CastCrew);
    function CastCrew(event:MouseEvent):void {
    gotoAndPlay(111)
    }

    BlgNws.addEventListener(MouseEvent.CLICK, BlogNews);
    function BlogNews(event:MouseEvent):void {
    navigateToURL(new URLRequest(“http://www.shores.blogspot.com/”));
    }

  124. can you tell me how do i aquire success on this function:

    tryin to parse the tweener target dynamically

    import caurina.transitions.*;
    var countNumber;
    var tgt:String;
    function go():void {
    for (count = 1; count < 10; count++) {
    tgt = ‘e’ + conta;
    Tweener.addTween(tgt, { ……. });
    }
    }

  125. Robert,

    I tried your code with 2 movieClips on the stage in all frames. With your code the example works fine for me. Because of this I would assume (without being able to see your whole file) that a movieClip is not on the stage or something similar.

    Actually, the second error may disappear if you resolve the first. It sounds like a movieClip is trying to be turned into a button.

    Thanks,

    Curtis J. Morley

  126. hi,
    I’m getting the 1009 error whie accessing the button instance. everything looks fine, and i can’t figure it out. here’s the code:

    apps.addEventListener(MouseEvent.CLICK, clickapps);
    function clickapps(event:Event):void{
    trace(“apps”);
    gotoAndStop(“apps”);
    }
    entrees.addEventListener(MouseEvent.CLICK, clickentrees);
    function clickentrees(event:Event):void{
    trace(“entrees”);
    gotoAndStop(“entrees”);
    }

    this is the full error message:

    apps
    TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@1ec786a1 to flash.display.SimpleButton.

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at barcelona_fla::MainTimeline/barcelona_fla::frame10()

    thanks for your help.
    robert

  127. Sorry for some reason some of my code from the previous post did not submit

    click=”logon()”

  128. I am getting the 1009 error doing something a little differently from others. I have posted my question on the adobe forums, but haven’t able to get a response. I have a button click action:

    The logon function

    private function logon():void
    {
    userSession.userId = userId.text;
    userSession.password = password.text;
    var token:AsyncToken = UserSessionAssembler.createItem(userSession);
    token.operation = “CREATE”;
    }

    The userSession object is being created in the init method, and that is being called on creationComplete

    private function init():void
    {
    userSession = new UserSession();
    }

    The UserSession class is an actionscript class which I created and is mapped to a java class.

    package assets.actionscript
    {
    [Bindable]
    [RemoteClass(alias=”UserSession”)]
    public class UserSession
    {
    public var userId:String;
    public var password:String;
    public var status:String;

    public function UserSession()
    {
    }

    public function getStatus():String {
    return this.status;
    }

    public function setStatus(status:String):void {
    this.status = status;
    }

    public function getUserId():String
    {
    return this.userId;
    }

    public function setUserId(userId:String):void
    {
    this.userId = userId;
    }

    public function getPassword(password:String):String
    {
    return this.password;
    }

    public function setPassword(password:String):void
    {
    this.password = password;
    }
    }
    }

    If I call the create method directly in the click function I can pass the object to the java class fine and it works, but for some reason when the object userSession is passed to the create method it throws the 1009 error. I have been stuck on this for a few days and has been very frusturating trying to resolve this.

  129. Peter,

    I am glad that this helps. It is worth the extra effort to get the benefits of AS3. Hopefully I will be of more help for you in te future.

    Thanks,
    Curtis J. Morley

  130. Man, thanks alot! I have been scratching my head over this error and I was even considering going back to using AS 2.0.

    I had movie clips inside another movie clip and your explanation really hit home.

    Thank you again!

  131. Working with external text in flash CS3 to create a website using external txt.

    I am using menu buttons in the main stage to change text the main external text box. Everything works fine. I added a two buttons on the sections stage to change the the text in the external text box. and i get this error:

    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at TAQA_fla::MainTimeline/frame1()

    I have the buttons codes as:

    sections.berry_btn.addEventListener(MouseEvent.CLICK,b8Listener);
    sections.skinner_btn.addEventListener(MouseEvent.CLICK,b9Listener);

    then:

    function b8Listener(event:MouseEvent):void {
    loadFile(“berry.txt”);
    sections.gotoAndStop(“artist”);
    }

    function b9Listener(event:MouseEvent):void{
    loadFile(“skinner.txt”);
    sections.gotoAndStop(“skinner”);
    }

    Do you need to see the whole code. What do i need to get my buttons to work with out having them on the main stage.

  132. Hey.
    I’m getting this error only when I use this script:
    this.introfilmcontainer.skipknap_mc.buttonMode = true;
    introfilmcontainer.skipknap_mc.addEventListener(MouseEvent.CLICK, skipknap);
    function skipknap(e:MouseEvent):void {
    introfilmcontainer.removeChild(introfilm);
    gotoAndPlay(“intro”);
    }
    Its only when I actually USE it. When I don’t use the button everything’s fine…
    What could be my problem?

  133. Pingback: Common ActionScript 3 Errors and Explanations | Jake Rutter - Designer and XHTML/CSS/ActionScript 3 Developer

  134. Pingback: curtismorley.com » Search Engine Optimization Example

  135. Pingback: Flex Community Blog » Blog Archive » Flex/Flash TypeError: Error #1009: Cannot access a property or method of a null object reference

  136. Hi there Curtis… I am a huge fan of your site and I use it all the time, although this is my first comment. Most of the time I come to your site and I find it very helpful, usually reading your detailed descriptions of errors helps me figure out what is going on with my AS3 code… but Finally I have run into an issue which has completely stumped me! This is why I am posting on your site.

    I have been working on an AS3 version of objects in 3d space, and I have based this on Paul Ortichanian’s version of the code ( http://reflektions.com/miniml/template_permalink.asp?id=459 ) which he developed in the main timeline of an FLA. I have ported the code over to a class, but for some reason I keep getting this error, #1009, which has pretty much become my arch nemesis! Is there any way I could get you to take a quick look at my code to see if you can spot whats wrong?…it would be greatly appreciated!
    feel free to send me an email and I can send over the FLA etc.

    Thanks so much for your help and great work with the site!… you are helping build the AS3 community through your generosity!

  137. Hi guys,

    I’m new to Flash & actionScript 3.0 I keep getting the same error as everyone
    TypeError: Error #1009: Cannot access a property or method of a null object reference.at bhbHome_fla::MainTimeline/frame1()
    I’m building a simple website and trying to control movies with “label frames”

    the first code works fine the button “beer_btn” works fine but when I click on the lightH_btn” it doen’t work, I deleted this last button code and the error went away, which means that that’s where the problem is 🙁
    If anyone can help me, it will greatly appreciated

    Thanks

    Mady

    here is my code:

    stop();

    function playBeers(event:MouseEvent):void
    {
    this.gotoAndStop(“beers”)
    }

    function playLight(event:MouseEvent):void
    {
    gotoAndPlay(“light”)
    }

    arrowUM.beer_btn.addEventListener(MouseEvent.CLICK, playBeers);

    lightH_btn.addEventListener(MouseEvent.CLICK, playLight);

  138. Hi again,

    i’m trying in timeline to create new object witch will stop scene playing until I get mouse event(that is just for lerarning, easiest way for me I think).. Here is the code from timeline..

    import vrnjci.uvod.*;

    var zaDugme = new UlaznaKlasa();

    Now, my way that I’m trying to do in constructor is to stop playing the scene, and listener for event like this..

    package com.vrnjci.uvod {
    import flash.display.*;
    import flash.display.Stage;
    import flash.events.*;

    public class UlaznaKlasa extends MovieClip{
    public function UlaznaKlasa(){
    stop();

    addEventListener(MouseEvent.MOUSE_MOVE, MouseListener);
    }

    public function Zavrsi():void{
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, MouseListener);
    }

    private function MouseListener(e:Event):void{
    trace(“RADI!!!!”);
    }

    public function Main():void{

    }
    }
    }

    I haven’t found much useful examples or books online, so any help would be largely appreciated :)..

  139. Hi Matthew,

    the reason is, you might not have assigned a variable name to section1

    i.e if you included above script in a frame and that frame *should have* an Object with instance name section1

    thanks
    ramesh

  140. help pls

    at frame 1 i put these lines:

    ========================

    btnTest.addEventListener(
    MouseEvent.MOUSE_UP,
    function(evt:MouseEvent):void {
    gotoAndPlay(“Finish”);
    }
    );

    stop();

    ========================

    what if btnTest is on Frame5?
    what will i do to put all AScodes in single frame but then can access symbols or instance names that will load at later frames?

    I do not want to put AS codes where and exaclty the btn will appear.
    🙂

    thank u

  141. Update: the error I get exactly is:

    Error #1009: Cannot access a property or method of a null object reference.
    at banner_250x240_fla::MainTimeline/banner_250x240_fla::frame27()

  142. Hi, I’m new to flash and new to action scripting. I have managed in the past to get a graphic as a button go to a url when pressed. BUt now I have decided to try and use Actionscript 3.0. This was mistake number 1 as it has removed the onPress value from the code, after about half an hour I have come up with the code which seems to work once then comes up with the 1009 error.

    My code is as follows. I have also checked it for errors and it says there is none. I have also made sure that each handler has a different tag as to not get confused.

    Just for you to know each of my images/buttons are labeled as section1 and so on up to 4.

    this.section1.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler1);
    function mouseDownHandler1(event:MouseEvent):void {
    navigateToURL(new URLRequest(“http://www.mysite.com/”));
    }

  143. I am getting this error and can’t figure it out. If anyone can help me it would be appreciated.

    TypeError: Error #1009: Cannot access a property or method of a null object reference. at siter_fla::MainTimeline/siter_fla::frame1()

    this error pops up when I enter code. I tested the code by itself in a different flash file and it works fine, but as soon as I add it to my website that has other code in it it stops working and I get this error.

    here is the code I added

    var myloader:Loader = new Loader();

    fe1_btn.addEventListener(MouseEvent.CLICK, image1);
    function image1(event:MouseEvent):void {
    var request:URLRequest = new URLRequest(“1.gif”);
    myloader.load(request);
    addChild(myloader);
    myloader.x=486;
    myloader.y=198;

    }

    fe2_btn.addEventListener(MouseEvent.CLICK, image2);
    function image2(event:MouseEvent):void {
    var request:URLRequest = new URLRequest(“2.gif”);
    myloader.load(request);
    addChild(myloader);
    myloader.x=486;
    myloader.y=198;

    }

  144. CK,

    Great tip. Thanks for the comment.

    Josh,

    Sorry about the head trauma man. Often times commenting out code will give this error because it actually makes the value null. Be careful when commenting out code that you are not removing a value that is needed later in the code.

    Bojan,

    The syntax stage.addEventListener(MouseEvent.MOUSE_MOVE, MouseListener); is proper and will work by itself and the function MouseListener. It seems that the error is not on this line but rather somewhere else in the code. If you can give me more code I would be happy to help you out with it.

    Thanks,
    Curtis J. Morley

  145. i’m getting this error, because I try to access stage like this “stage.addEventListener(MouseEvent.MOUSE_MOVE, MouseListener);”, but I dont think this is right way to do, but cannot find answer anywhere. Can you help me?..

  146. If you use the mxml argument -verbose-stacktraces=true the error will also output the line number where the null pointer exception was thrown. Seems to be a huge time saver for me while developing.

  147. Error 1009 is probably the worst trash error EVER! It doesn’t tell you where the error is. It just says 1009 bla bla bla. I can take like the whole day to fix it. And it’s not because I did not know what I was doing, one moment there is no error, the next, it is there. And I never touched the code of the function that initiated the error. I was working on another part. I tried to block some codes in that function to narrow down where the error was and guess what, the error still appeared no matter what. My head is now bleeding and the wall is demolished and the error is still there.

  148. I am using an invisible button to keep my main video from downloading, found here…

    http://blog.sessions.edu/web-design/how-to-save-bandwidth-when-displaying-flash-video/

    My goal is to make a video player that acts much like the one that YouTube uses. If you click on the image, the video will load, and if you click on the play button, the video will load.

    I have an FLVPlayback component on the stage on the bottom layer, and an invisible rectangle button on the layer above, over the image portion of the FLVPlayback. The FLVPlayback is named “thePlayer”, and the invisible button is named “theButton”. The actions layer is above the other two, and each layer just has one frame.

    To get the play button to work as I want it to, I have the FLVPlayback component first load the “splash.flv” file, which is just a still image. I then used ActionScript to add a cue point 0.001 seconds into the video. When the cue point hits, it then loads the actual video.

  149. Nate,

    According to your code you haven’t yet instantiated ‘thePlayer’ or ‘theButton’., unless these are on your stage. If you comment out any of the lines that start with thePlayer. you will see that the error goes away. This may be the reason for the error.

    Tell me how you have your Flash file set up so that I can help you debug a little better.

    Thanks,
    Curtis J. Morley

  150. I’m new to Flash, and I can’t quite figure out why I would be getting this 1009 error. Do you have any ideas why I might be getting the error with the following code?…

    import flash.events.EventDispatcher;
    import fl.video.*;

    thePlayer.source = “splash.flv”;

    var theCuePoint:Object = new Object();
    theCuePoint.time = 0.001;
    theCuePoint.name = “main_video”;
    thePlayer.addASCuePoint(theCuePoint);

    function splashCuePoint(evt:MetadataEvent):void {
    loadVideo();
    }

    thePlayer.addEventListener(MetadataEvent.CUE_POINT, splashCuePoint);

    function buttonClick(evt:MouseEvent):void {
    loadVideo();
    }

    theButton.addEventListener(MouseEvent.CLICK, buttonClick);

    function loadVideo():void {
    thePlayer.source = “main_video.flv”;
    thePlayer.play();
    theButton.enabled = false;
    theButton.visible = false;
    }

Comments are closed.