10 Replies Latest reply on Sep 7, 2007 12:48 AM by ritpas

    How to add MC to root stage from within a class?

    ritpas Level 1
      Hi,

      I have 2 files test.fla and Test.as
      Here is Test.as' content :
      package {
      import flash.display.MovieClip;
      public class Test{

      function Test(){
      var mc:MovieClip=new MovieClip();

      mc.graphics.lineStyle();
      mc.graphics.beginFill(0x990000,100);
      mc.graphics.drawRect(0,0,300,200);
      mc.graphics.endFill();
      stage.addChild(mc);

      }
      }
      }

      test.fla contains only the following code at frame 1 : var test:Test=new Test();
      It doesn't work:(
      My question : how to add a new MovieClip to the root stage only from within a class?
      Under AS 2.0, we got the _root object as reference, but now under as 3.0 how do I call the root stage?

      thanks for your help