Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Error #1009 when loading SWF with Document Class

Community Beginner ,
Jun 28, 2015 Jun 28, 2015

Hello,

I have two SWFs, racingPreloader.swf and racingTrack1.swf, the second one has a document class "mains.RaceMain".

racingPreloader.swf is a preloader for racingTrack1.swf, but it doesn't work. Instead, I get the output:

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

    at mains::RaceMain()

I tried permitting debugging on both files, and testing it with Shift+Ctrl+Enter, but the output is about the same; it doesn't give me an specific line where the problem is.

Attempting to launch and connect to Player using URL H:\Swifter\racingPreloader.swf

[SWF] H:\Swifter\racingPreloader.swf - 16102 bytes after decompression

[SWF] H:\Swifter\racingTrack1.swf - 41869 bytes after decompression

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

    at mains::RaceMain()

Cannot display source code at this location


This is very similar to what happened at this thread, but I couldn't solve my problem after not finding a solution in it.


Here is the code of frame 1 of racingPreloader.swf:


var loader:Loader = new Loader();

loader.load(new URLRequest("racingTrack1.swf"));

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,openSWF);

function openSWF(e:Event) {

    addChild(loader)

}

And here is some of the code at mains.RacingMain class. I omitted most of the code because I believe only these lines are the cause of the problem:

package mains {

     import flash.display.MovieClip;

     //...More import clausses

     public class RaceMain extends MovieClip {

          public function RaceMain() {

                 if(stage==null)

                     this.addEventListener(Event.ADDED_TO_STAGE,main);

                 else

                     main(null);

          }

       

          private function main(e:Event):void {

             //start the game

          }

     }

}


Thank you.

TOPICS
ActionScript
369
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jun 28, 2015 Jun 28, 2015

I just figured that I was loading an older version of racingTrack1.swf with an unfixed version of the mains.RaceMain document class. I changed it to the version with this fix and finally got it to work.

Translate
Community Beginner ,
Jun 28, 2015 Jun 28, 2015
LATEST

I just figured that I was loading an older version of racingTrack1.swf with an unfixed version of the mains.RaceMain document class. I changed it to the version with this fix and finally got it to work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines