2 Replies Latest reply on Apr 19, 2009 8:09 AM by Gregory Lafrance

    dynamic creation strategy ?

    phil1943 Level 1

      Hello, my users will create numerous textArea components.

      As each of these is created I will add them to an array.

      Each of these array elements needs to have an eventListener which call a global startDrag function.

      What is the best strategy to dynamically create/name these textArea components as the users start requesting their creation ?

      ie. they will not all be created at once, so I cant use a loop to generate them.


      thanks kindly for any advice

        • 1. Re: dynamic creation strategy ?
          ATIF FAROOQ Level 3


             If you want to create all TextArea comps at once you can do something like this.Or you can create each new textArea when you want to show it to the user.


                      var prefix:String='myPrefix'
                      var temp:TextArea;
                      var totaltextareaComps:int=10
                      for(var i:int=0;i<totaltextareaComps;i++){
                          temp=new TextArea()
                          //set further properties of textArea component here according to your needs
                          //replace this with  name of your parent container.
          • 2. Re: dynamic creation strategy ?
            Gregory Lafrance Level 6

            You may find this useful:


            private var numTextAreas:int = 0;

            private var textAreaArray:Array = new Array();

            private var prefix:String ="myPrefix";

            private function createTextArea():void{


                var temp:TextArea to new TextArea();


                temp.addEventListener(YOUREVENT, startDrag);