Hi I’m new to AS3, I hope you guys can help me. I have this error when I run the files.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.common::stageConfig()
at cloudsMain()
CloudsMain.as which is attached to the .fla
package {
import flash.display.MovieClip;
import com.common.stageConfig;
public class cloudsMain extends MovieClip {
public var _stageConfig:stageConfig;
public function cloudsMain () {
_stageConfig = new stageConfig ();
}
}
}
The external class which is called.
package com.common{
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.display.DisplayObject;
import flash.events.Event;
public class stageConfig extends MovieClip {
public function stageConfig ():void {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
}
public function centralisedDO (_do:DisplayObject):void {
_do.x = stage.stageWidth / 2;
_do.y = stage.stageHeight / 2;
trace ("centralised "+_do+" at "+_do.x+","+_do.y);
}
}
}
Basically I’m trying to create a class that I can call and centralise any mc on stage by eg.
stageConfig.centralisedDO(my_mc), However I encounter the above error.
Please advice.