4 Replies Latest reply on Mar 28, 2010 8:00 PM by kglad

    Dynamically adding combobox and other controls to new empty movie clip via AS2

    Denis64_Sarrazin

      Hi,

       

      I'm using Flash Pro CS4, and ActionScript 2, and I'm trying to create objects dynamically, through code, rather than through the designer in Flash. Here is a code snippet to give you an idea:

       

      // create movie clip

      converter_mc = target.createEmptyMovieClip ("converter", depth);

      converter_mc._x = x;

      converter_mc._y = y;

       

      //... add various controls such as the following:

      cboTest = converter_mc.createClassObject (ComboBox, "picker", converter_mc.getNextHighestDepth()); // <-- this does not work

      cboTest.setSize (200, cboTest.height);

      cboTest.move (cboTest.x, 10);

      cboTest.dataProvider = [{label:"Select Target Currency", data:null}, {label:"Canadian to U.S. dollar", data:"US"}, {label:"Canadian to UK Pound Sterling", data:"UK"}, {label:"Canadian to Euro", data:"EU"}];

       

      // convert_mc.addChild(cboTest); // <-- this does not work

       

      I tried using the converter_mc.createClassObject but that seems to be something that existed in previous versions of Flash but has changed (to what, I can't figured out). I've also seen examples of the addChild but I think this might be only in AS3 and it also does not appear to work for me in AS2.

       

      Any suggestions/thoughts on how I can add components to a new movie clip via ActionScript 2?

       

      Thanks,

      -D