PDA

View Full Version : Stage EventListener not working


firdosh
12-02-2006, 12:53 PM
I created a as3 project and my main class extends sprite


package{
public class MyClass extends Sprite{

public function MyClass(){
this.stage.addEventListener(Event.RESIZE,onresize) ;
}

private function onresize(e:Event):void{

trace("resize");
}
}

but I cannot see the trace statements. Any ideas ??

cheers
firdosh


}

senocular
12-02-2006, 03:10 PM
make sure you are importing Sprite and Event. Also are you using MyClass as the document class? If not, you may not have access to stage in the constructor.

firdosh
12-02-2006, 08:22 PM
I did import both the classes and moved the

this.stage.addEventListener(Event.RESIZE,onresize) ;

to a init function but still no trace statment.

I could not find a on load or complete event for the Sprite class , although in the init function when i trace out this.stage, it traces out fine

firdosh

firdosh
12-03-2006, 02:39 AM
figured it out

stage.scaleMode = StageScaleMode.NO_SCALE;

Need to add this to the constructor as well.

cheers :)
firdosh