5 Replies Latest reply on Sep 30, 2011 3:42 PM by Andrei1

    TypeError: Error #1007: Instantiation attempted on a non-constructor... sometimes

    ZinreF

      package{

                import flash.display.MovieClip;

                import flash.events.MouseEvent;

       

                public class MainTimeline extends MovieClip{

       

                               private var movieArray:Array = new Array(8);

                               private          var myMovieClip:Array = new Array(18);

                               private          var sco:Array = new Array(6);

       

                               private var i:Number = 0;

                               private var rangeX:Number = 0;

                               private          var sumScore:Number = 0;

       

                               public function MainTimeline(){

       

                                              movieArray = [tele01, tele02, tele03, tele04, duck01, monkey01, pig01, boom01]; //Animation MovieClip from library

                                              myMovieClip = [myMovieClip1, myMovieClip2, myMovieClip3, myMovieClip4, myMovieClip5, myMovieClip6]; //Blank MovieClip from library

       

                                              for (i = 0; i < 6; i++)

                                              {

                                                             var number:Number = Math.floor(Math.random() * 9);

                                                             myMovieClip[i] = new movieArray[number]; //create Animation MovieClip to Blank MovieClip

                         myMovieClip[i].x = rangeX;

                                                             myMovieClip[i].y = 90;

                                                             sco[i] = 50;

                                                             addChild(myMovieClip[i]);

                                                             rangeX += 132;

                  }

                 myMovieClip[0].addEventListener(MouseEvent.CLICK, disappear1);

                 myMovieClip[1].addEventListener(MouseEvent.CLICK, disappear2);

       

                 function disappear1(e:MouseEvent):void {

                                                            myMovieClip[0].visible=false;

                        sumScore = sumScore + sco[0];

                        score.text = sumScore.toString();

                  }

       

                                          function disappear2(e:MouseEvent):void {

                                                        myMovieClip[1].visible=false;

                                                        sumScore = sumScore + sco[1];

                                                        score.text = sumScore.toString();

              }

             }

           }

      }

       

      I am a Newbie of AS3 and I dont't undersatnd why this code can run successfully sometimes, sometimes not and told me "TypeError: Error #1007: Instantiation attempted on a non-constructor."

       

      Please, help me... I try to solve anything. Thank you.