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


#1

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.


#2

Have you used stage at all for example:

stage.stageWidth

in your conceptGallery.swf?


#3
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.


#4

There’s your problem.

Use ADDED_TO_STAGE and include all you stage statements in there.


#5
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?


#6
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

}


#7

Resolved


#8

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: