#1009: Cannot access a property or method of a null object reference.
I have been trying to solve this on my own but have not been succcessful as of yet so I am reaching out hoping for help.
I have a full screen flash video slideshow homepage. the preloader is on frame 1 the first slide is on frame 2, the second slide is on frame 3 and so on.
The actionscript on frame 1 first states NO_SCALE,
then aligns the stage to top left,
then sets the width of the asset with regard to the width of the stage,
then creates the aspect ratio var
then sets the scaleY based on the ratio.
Here is where I get errors:
I have an event listener with a resize trigger.
When the stage is resized a function is called that changes the dimensions of the asset (same formula as before)
However when I resize the stage after "Test Movie" IDE reports errors:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at homepage_fla::MainTimeline/onStageResize()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at homepage_fla::MainTimeline/onStageResize2()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at homepage_fla::MainTimeline/onStageResize3()
The functions mentioned in the errors are the specific functions for each slide so here the first second and third slides threw an error on resize.
I have seperate functions in the actions of each slide frame but am only calling the noscale and alignstage in the second frame.
I do not seee extra code that may be fouling the code indicated here though I guess that could be possible, but the only other code (slideshow AS) works sans errors without the resize code.
CODE IN FRAME 1
// Set stage to no scale
stage.scaleMode = StageScaleMode.NO_SCALE;
//Align To Top Left
stage.align = StageAlign.TOP_LEFT;
mc_Asset1.scaleX = stage.stageWidth/1920;
var ratio = 4/3;
mc_Asset1.scaleY = (stage.stageWidth/1920) * ratio;
stage.addEventListener(Event.RESIZE, onStageResize);
function onStageResize(evt:Event):void {
mc_Asset1.scaleX = stage.stageWidth/1920;
mc_Asset1.scaleY = (stage.stageWidth/1920) * ratio;
}
wait(7);
...slide show AS below...
CODE IN FRAME 2
mc_Asset2.scaleX = stage.stageWidth/1920;
mc_Asset2.scaleY = (stage.stageWidth/1920) * ratio;
stage.addEventListener(Event.RESIZE, onStageResize2);
function onStageResize2(evt:Event):void {
mc_Asset2.scaleX = stage.stageWidth/1920;
mc_Asset2.scaleY = (stage.stageWidth/1920) * ratio;
}
wait(7);
...slide show AS below...