get access to stage object


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. package
  2. {
  3. import flash.events.Event;
  4.  
  5. public class MyClass extends MovieClip
  6. {
  7. public function MyClass()
  8. {
  9. super();
  10. addEventListener(Event.ADDED_TO_STAGE,added);
  11. // stage is null; try trace(stage.stagewidth); ==> null object
  12. }
  13.  
  14. public function added(evt:Event):void{
  15. removeEventListener(Event.ADDED_TO_STAGE,added);
  16. // stage is not null; try trace(stage.stagewidth); ==> somevalue
  17.  
  18. }
  19. }
  20. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.