Moving function to external .as file

Hello.

I’ve started to learn class based AS3, and I came across the problem that I can’t find the solution for.

My current code:

 
package 
 {
 import flash.display.MovieClip;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import flash.events.Event;
 
 [COLOR=blue]import config.ProjectConfig;[/COLOR]
  
 public class Main extends MovieClip {
 
  public var projectConfig:ProjectConfig = new ProjectConfig();
[COLOR=blue] public var mainBg:MovieClip = new MovieClip();[/COLOR]
 
  public function Main() {
   initStage();
   initMainBg();
  }
 
  private function initStage():void {
   stage.scaleMode = StageScaleMode.NO_SCALE;
   stage.align = StageAlign.TOP_LEFT;
  }
 
  private function initMainBg():void {
  [COLOR=blue] mainBg[/COLOR].graphics.beginFill([COLOR=blue]projectConfig.projectBgColor[/COLOR]);
[COLOR=blue]  mainBg[/COLOR].graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
  [COLOR=blue] mainBg[/COLOR].graphics.endFill();
   addChild([COLOR=blue]mainBg[/COLOR]);
  }
}
}

Now I’d like to move function initMainBg() to separate file ([COLOR=blue]engine.as),[/COLOR]
but when I just cut/paste it into the engine.as package, it looks it has no reference to [COLOR=blue]mainBg [/COLOR]created within[COLOR=blue] Main.as[/COLOR] as well I can’t use [COLOR=blue]projectConfig.projectBgColor[/COLOR] variable ([COLOR=blue]stored in ProjectConfig.as[/COLOR]).

Can somebody guide me, how the engine.as should look like to be able to work with both references?
And also how to reference from this function to stage.stageWidth?

Thanks!