I am trying to do something like this:
package com.clicker{
import flash.display.*;
import flash.events.MouseEvent;
public class Stager extends MovieClip {
public function clicker():void {
stage.addEventListener(MouseEvent.CLICK, do_stage);
}
function do_stage(e:MouseEvent):void {
trace("stage clicked");
}
}
}
But, I get the 1009 error.
When I do this:
import com.clicker.*;
var test:Stager = new Stager();
test.clicker();
addChild(test);
Please help me. Thank you very much in advance, and Happy Holidays.
since you call
test.clicker();
before it added to the stagetest
doesn't have a this.stage object yet try :}
hope this helps...
stage is accessible only when your component is added to the stage. If you want to know it, you can use the ADDED_TO_STAGE event.
So, you can do this :