Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now