Unless the object is on the display stage, the stage
object will be undefined (or null). You have to addChild
the object for the stage
object to have a value.
Edit: Perhaps you can handle this in the event handler?
protected function clickHandler(e :Event) :void {
if (e.target.stage) {
e.target.stage.removeEventListener(...);
}
}
Edit2: Static methods don't have a stage, so to solve your problem you can make your Main-class a singleton, and work like this:
public class Main {
static private var instance :Main;
static public function getInstance() :Main {
if (Main.instance == undefined) {
Main.instance = new Main();
}
return Main.instance;
}
// The rest of the class goes here
}
// snip
import Main;
public static function disableVcam():void {
trace("disable");
Main.getInstance().stage.removeEventListener(MouseEvent.MOUSE_MOVE, movevC);
}
If your Main-class is the main class of the project, you need to assign the static instance
variable's value in the constructor.