1 Reply Latest reply on Oct 16, 2007 3:20 AM by Newsgroup_User

    help for dynamic class name

    socratesTaiwan Level 1
      In actionscript 2.0, the following codes dynamically attach a symbol
      in the library to the stage:

      var i:Number=Math.floor(Math.random*10);

      where symbol0 ~ symbol9 are linkage id of 10 symbols in the library.
      While in ActionScript 3.0, I have a difficulty doing similar thing.
      If I want to attach a symbol to the stage, the code may look like

      var a_mc:MovieClip=new Symbol0();

      but I don't know how I can attach randomly

      1 var i:int=Math.floor(Math.random()*10);
      2 var a_mc:MovieClip=new [Symbol+i]();
      3 this.addChild(a_mc);

      I found I need script like line 2, but it doesn't work obviously.
      Is the convenient way to do this?
      thanks very much for help!