Hi all,
I have one movieclip in (my.fla) and I’m trying to use the linkage to give a classname of “bgMC” to it. Unlike as2, there’s no more identifier.
The compiler gives me that error:
Error #1009: Cannot access a property or method of a null object reference.
while running debug in flash cs3, it stops at line:
this.backgroundMC.width = stage.stageWidth;
It can’t recognize the linkage that I have declared.
Does anyone know how to fix that?
The idea here is basically I want to reuse this class that I’ve made on others projects.
my main class:
package src
{
import manageBG.bgFullScreen;
private var bgScreen:bgFullScreen;
private var test:MovieClip = new bgMC();
public class main extends Sprite
{
public function main():void
{
this.bgScreen = new bgFullScreen(test);
}
}
}
bgFullScreen class:
package manageBG
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.display.MovieClip;
public class bgFullScreen extends Sprite
{
private var backgroundMC:MovieClip;
public function bgFullScreen(mc:MovieClip)
{
this.backgroundMC = new MovieClip();
this.backgroundMC = mc;
this.positionBG();
this.initStage();
}
private function initStage():void
{
stage.addEventListener(Event.RESIZE, handleBG);
}
private function handleBG(evt:Event):void
{
this.positionBG();
}
private function positionBG():void
{
this.backgroundMC.x = 0;
this.backgroundMC.y = 0;
this.backgroundMC.width = stage.stageWidth;
this.backgroundMC.height = stage.stageHeight;
addChild(backgroundMC);
}
}
}