3 Replies Latest reply on Sep 13, 2013 3:02 PM by Ned Murphy

    1136: Incorrect number of arguments.  Expected 1.

    Charine -FB buggoop Level 1

      Hi There


      I have a main class file and another class file with a function in that I want to call from the main class. when I addChild the second class in the main class file I get 1136 error - incorrect number of arguments.


      How do I solve this error message?


      Here is the code in my main class file:




          import flash.display.*;

          import flash.utils.*;

          import flash.events.*;

          import flash.media.*;

          import flash.text.*;



          public class BugGoopFSGame extends MovieClip


              public var mybackground:BackGround;

              public var cinders:Cinders;

              public var gameTimer:Timer;

              public var spidy:Spidy;

              public var myplaybtn:Play;

              public var timerback:TimerBack;

              public var timermiddle:TimerMiddle;

              public var timerfront:TimerFront;

              public var settings_btn:Settings_btn;

              public var sound1:Sound1 = new Sound1();

              public var sound3:Sound3 = new Sound3();

              public var channel:SoundChannel = sound1.play(0,int.MAX_VALUE)

              public var st:SoundTransform = channel.soundTransform;

              public var scoreText:ScoreText = new ScoreText();


              var wordArray:WordArray;


              public var wordtext:wordText;

              public var letterA = new A ();


              //**Constructor Function

                  public function BugGoopFSGame()




                 gameTimer = new Timer(31,5120);


                  //Add event listener for start button

                  myplaybtn.addEventListener(MouseEvent.CLICK, startTimer);




                  //Start timer function

              public function startTimer(timerEvent:MouseEvent):void



                  trace("Game Timer started");

                  myplaybtn.visible = false;


                 scoreText = new ScoreText();



                  wordtext = new wordText();


                  trace("WordText Box Added");


                  wordArray = new WordArray(); //as soon as I add this, I get the error message




        • 1. Re: 1136: Incorrect number of arguments.  Expected 1.
          Ned Murphy Adobe Community Professional & MVP

          The error appears to be insdicating that your WordArray class constructor is expecting an argument to be passed to it.


          wordArray = new WordArray(?????);

          • 2. Re: 1136: Incorrect number of arguments.  Expected 1.
            Charine -FB buggoop Level 1

            Hi Ned,


            The above is an attempt and  test I made to see how I could get functions from my WordArray class file to be called from my main class (called BugGoop.as)


            You helped me to build a fucntion in the WordArray class file, but I could never get it to show up in my swf file. I think this is because the file is never called from the main class file. I need to know how to call the function in the wordArray class to the main class shown at the beginning of this question so that it can be part of my swf game.


            Here is the wordArray class again. I want to see this MC in the swf: function initLetterTiles():void


            Thanks for taking a look







                import flash.display.*;

                import flash.text.TextField;

                import flash.events.Event;   

                import flash.utils.Timer;

                import flash.events.*;

                import flash.events.MouseEvent;

                import flash.media.Sound;

                import flash.media.SoundChannel;


                public  dynamic class WordArray extends MovieClip


                            public var wordtext:wordText =  new wordText;

                            var activeWordArray:Array;

                            var activeLevelofTenWordsArray:Array;

                           var activeLevelofTilesArray:Array;

                            public var letterArray:LetterArray;

                            var tileTimer = new Timer(500,384);


                    //Movie clips of letter tiles to be used

                    public var a:A = new A();

                    public var f:F = new F();

                    public var g:G = new G(); //etc. for all mc's


                    private var wordArray:WordArray;


                    private var letterTiles:Array = [a,f,g..etc];

                                          private var  lettersL01:Array = [a,a,f,f,f,g,g,h,h,i,i,n,n,n,o,o,o,o,s,s,t,t,t];

                                          private var  lettersL02:Array = [th,th,  //etc for all levels..


                                        public var letterLevels:Array = [lettersL01,lettersL02,lettersL03,lettersL04,lettersL05,lettersL06,le ttersL07,lettersL08,lettersL09,lettersL10,

                                                                                           lettersL11,lettersL12,lettersL13,lettersL14,lettersL15,lettersL16,let tersL17,lettersL18,lettersL19,lettersL20,

                                                                                           lettersL21,lettersL22,lettersL23,lettersL24,lettersL25,lettersL26,let tersL27,lettersL28,lettersL29,lettersL30];


            public var  wordsL1W1:Array = ["a"];  //etc for all words


            public var  wordsL01:Array = [wordsL1W1,...etc for all levels];


            public var wordLevels:Array = [wordsL01,wordsL02,...etc. for entire word array]


                            private var tf:TextField;


                            // ***constructor code

                            public function WordArray(_tf:TextField)


                                tf = _tf;





                            function levelGenerator():void


                                //**To get next level of 10 words








                                //Game is complete




                            function activeLevelofTenWords():void


                                // na



                            function tileGenerator():void








                                        //Game is complete





            function activeLevelofTiles():void


                                    activeLevelofTilesArray = letterLevels.shift();




                                function initLetterTiles():void


                                    for(var j:int=0; j<3; j++)

                                     {  shuffle(activeLevelofTilesArray);

                                        for (var i:int=0; i < activeLevelofTilesArray.length; i++)


                                            trace (activeLevelofTilesArray[i]);

                                            activeLevelofTilesArray[i].x = 399;

                                            activeLevelofTilesArray[i].y= 30;






                                        function shuffle(a:Array)


                                            var p:int;

                                            var t:*;

                                            var ivar:int;

                                            for (ivar = a.length-1; ivar>=0; ivar--)



                                                t = a[ivar];

                                                a[ivar] = a[p];

                                                a[p] = t;




            • 3. Re: 1136: Incorrect number of arguments.  Expected 1.
              Ned Murphy Adobe Community Professional & MVP

              As I said, the WordArray class is requiring you to send it an argument:


                        public function WordArray(_tf:TextField)


              You have it requiring that a TextField be passed to it as an argument.  But in the code of your first posting you are not passing any argument to it.


              If you do not know why you required that argument, then you need to think back thru your design to figure why you have it and whether or not you still need it.

              1 person found this helpful