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

Hi,

I guess I should let you know what two files I’m working with on this project.

I’m using this external preloader…

…to load this gallery. I’m also going to be loading in 3 different galleries. But for now, I’ve only tested one.

Here’s my problem…

I have a main.swf that is going to load conceptGallery.swf, portraitsGallery.swf, and miscGallery.swf

So far I’ve only finished up conceptGallery.swf and it looks great when I’m looking at it by itself. But when I try and load it into my main.swf, I get this error:

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

I’ve looked around google but with not much luck :frowning:

Does anybody have any suggestions? This is my first time working in AS3, so any help would be greatly appreciated.

Thank you.

Have you used stage at all for example:

stage.stageWidth

in your conceptGallery.swf?

Have you used stage at all for example:

stage.stageWidth

in your conceptGallery.swf?

I believe so.

I read that as an answer when I was browsing through Google. But since I didn’t build the gallery myself, I’m not quite sure what to do edit and what not :slight_smile:

But looking through the first few lines, I found this:

var empty_mc:Loader=new Loader();
stage.addChild(empty_mc);
var swfStage:Stage = empty_mc.stage;
swfStage.scaleMode = StageScaleMode.NO_SCALE;
swfStage.align = StageAlign.TOP_LEFT;

Other than that, the only other thing involving “Stage” was for the full screen function.

There’s your problem.

Use ADDED_TO_STAGE and include all you stage statements in there.

There's your problem.

Use ADDED_TO_STAGE and include all you stage statements in there.

thePhoenix,

So replace everything that is stage.something to ADDED_TO_STAGE, or replace what is swfStage?

There's your problem.

Use ADDED_TO_STAGE and include all you stage statements in there.

thePhoenix,

So replace everything that is stage.something to ADDED_TO_STAGE, or replace what is swfStage?


addEventListener(Event.ADDED_TO_STAGE, setupStage);

function setupStage (e:Event):void {

// all stage statements in here

}

Resolved

Hi…

I am using AS3.0 preloader for load external swf
And i am getting error

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

When i put these code in my main swf

stage.scaleMode = StageScaleMode.SHOW_ALL;
stage.align = StageAlign.TOP;

below is the loader swf code

var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.load(new URLRequest("~certipath.swf"));

function progressHandler(event:ProgressEvent):void
{
var ratio:Number = event.bytesLoaded / event.bytesTotal;
percent.text = Math.ceil(ratio*100).toString();
bar.scaleX = ratio;

}

function completeHandler(event:Event):void{
removeChild(percent);
removeChild(bar);
removeChild(loading);
removeChild(countD);

removeChild(bgg);
percent = null;
bar = null;
addChild(loader);

}

Could please help me, I have searched a lot… but no luck…
what i do to resolve this problem and I also tried your code [posted above]… but loader didn’t call the main swf… :frowning: