10 Replies Latest reply: Sep 10, 2013 10:06 AM by Charine -FB buggoop RSS

    Movie clip not visible

    Charine -FB buggoop

      I the code below I want to add the following array of movie clips: activeLevelofTilesArray

       

      After I added the code below the swf plays with the following error:

       

      ReferenceError: Error #1069: Property [object S],[object T],...etc.

      not found on builtin.as$0.MethodClosure and there is no default value.

          at WordArray/startTileTimer()

          at WordArray/activeLevelofTiles()

          at WordArray/tileGenerator()

          at WordArray/levelGenerator()

          at WordArray()

          at wordText/initWordText()

          at flash.display::DisplayObjectContainer/addChild()

          at BugGoopFSGame/startTimer()

       

      I can also not see the movie clips.

       

      To try to trouble shoot this I ran a trace statement successfully and I turned off any graphics that might be in front of it. Why can't I see my movieclips and how do I fix error 1069?

       

      package

       

      {

          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,lettersL07,lettersL08, lettersL09,lettersL10,

                                                                                   lettersL11,lettersL12,lettersL13,lettersL14,lettersL15,lettersL16,lettersL17,lettersL18,l ettersL19,lettersL20,

                                                                                   lettersL21,lettersL22,lettersL23,lettersL24,lettersL25,lettersL26,lettersL27,lettersL28,l ettersL29,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;

                          levelGenerator();

       

                      }

       

                      function levelGenerator():void

                      {

                          //**To get next level of 10 words

                          if(wordLevels.length>0)

                          {

                              activeLevelofTenWords();

                              tileGenerator();

                          }

                          else

                          {

                          //Game is complete

                          }

                      }

       

                      function activeLevelofTenWords():void

                      {

                          // na

                      }

       

                      function tileGenerator():void

                      {

                          if(letterLevels.length>0)

                              {

                                  activeLevelofTiles();

                              }

                          else

                              {

                                  //Game is complete

                              }

       

                          }

       

                          function activeLevelofTiles():void

                          {

                              activeLevelofTilesArray = letterLevels.shift();

                              shuffleTiles(activeLevelofTilesArray);

       

                              startTileTimer();

                          }

       

                          function shuffleTiles(a:Array)

                          {

                              //works perfectly

                                          }

                              }

       

                          function startTileTimer():void

                              {

                                  tileTimer.start();

                                 trace(activeLevelofTilesArray);  // show in output pannel without errors

                                  activeLevelofTilesArray.x = 399;

                                  activeLevelofTilesArray.y= 30;

       

                                  addChild[activeLevelofTilesArray];    //can not see these in swf ***these show in output pannel with an error code ReferenceError: Error #1069: Property [object F],[object O],[object F],...etc

       

                                  trace("Letters should run"); //this shows in output pannel

                              }

       

       

      //rest not applicable..

        • 1. Re: Movie clip not visible
          Ned Murphy MVP

          addChild[activeLevelofTilesArray];

           

          The addChild function uses parentheses, not brackets

          • 2. Re: Movie clip not visible
            Charine -FB buggoop Community Member

            Hi Ned,

             

            If I do this:

             

            function startTileTimer():void

                                    {

                                        tileTimer.start();

                                        trace(activeLevelofTilesArray);

                                        activeLevelofTilesArray.x = 399;

                                        activeLevelofTilesArray.y= 30;

             

                                        addChild(activeLevelofTilesArray);

                                        trace("Letters should run");

             

                                        initTileWasClickedOn();

                                    }

             

             

            I get this error message:

             

            1067: Implicit coercion of a value of type Array to an unrelated type flash.display:DisplayObject.

             

            Maybe I must specify that these are MovieClips, but where? What do I do now?

             

            Thanks for helping

            Charine

            • 3. Re: Movie clip not visible
              Ned Murphy MVP

              Yes, I suspected the next error you'd encounter would involve you trying to treat an array like an object.  But if you don't experience the error you are more likely to repeat it for lack of realizing you made it.

               

              Each of these three lines is trying to treat an array like it is an object on the stage.  It might contain references to such objects but is by itself just an array,

               

                     activeLevelofTilesArray.x = 399; 

                     activeLevelofTilesArray.y= 30;

               

                     addChild(activeLevelofTilesArray);

               

               

              I don't know what the intention is, but you probably need to target individual elements of the array rather than the array.... as in... 

               

                     activeLevelofTilesArray[some_index].x = 399;

              • 4. Re: Movie clip not visible
                Charine -FB buggoop Community Member

                Hi Ned,

                Thanks for your help.

                 

                I tried to write a var to target the individual objects. At least there is no error code now, but I still can not see the mc letter tiles running.

                 

                Below is the code:

                 

                function activeLevelofTiles():void

                                    {

                                        activeLevelofTilesArray = letterLevels.shift(); //I think this must go first since I'm going to work with the objects inside activeLevelofTilesArray

                 

                                        for (var i: Number  =0; i < activeLevelofTilesArray.length*3; i++) //to show each tile 3 times (shuffled as per your shuffler below)

                 

                                          {

                                            var tile_index = (i%activeLevelofTilesArray.length);

                                          }

                                         

                                          function shuffleTiles(a:Array) //Can I add this function within a function or must I move it down?

                                        {

                                            var p:int;

                                                var t:*;

                                                var ivar:int;

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

                                                    {

                                                    p=Math.floor((ivar+1)*Math.random());

                                                    t = a[ivar];

                                                    a[ivar] = a[p];

                                                    a[p] = t;

                                                    }

                                            }

                                       

                                        shuffleTiles(activeLevelofTilesArray);

                                      

                                            tileTimer.start(); //not sure it I can add this many methods within a function

                                            trace(activeLevelofTilesArray);

                                            activeLevelofTilesArray[tile_index].x = 399;

                                            activeLevelofTilesArray[tile_index].y= 30;

                                           

                                            addChild (activeLevelofTilesArray[tile_index]);

                                            trace("Letters should run");

                                    }

                • 5. Re: Movie clip not visible
                  Ned Murphy MVP

                  Do not nest that shuffle function within the activeLevelofTiles function.  Move it out on its own.

                   

                  Use the trace command to see what the tile_index value is as the loop(s) processes.  See if it makes sense to you or not.  I don't know why you are trying to assign it a value in a loop.  It can only exit that loop with a single value.   You should be declaring the tile)index variable outside of that loop.

                  • 6. Re: Movie clip not visible
                    Charine -FB buggoop Community Member

                    Hi Ned,

                    Thanks, I moved the shuffle function out of activeLevelofTiles like you said and it still works. Yippeeeee

                     

                    I have 3 more issues that I need to sort out:

                     

                    1. I'm not doing this whole tile business correctly. As you predicted - If I trace the tile_index value I see only one tile eg. [object a]. It gives me a different one every time so I know the suffle function still works. I need for it to shuffle through the entire active level *3 so that "the tiles fall from the sky" individually generated by the timer that I have built. I guess I have to add it to an event handler.
                    2. Although the trace (activeLevelofTilesArray[tile_index]); worked, I still can not see even the one object generated in the swf file - I think this will solve itself when issue 3 is solved
                    3. After I descovered issues 1 and 2 above, I attempted to declare the tile_index variable outside of the loop. I must have done it wrong or incompletely because I get the following error messages on all the lines I used tile_index:

                     

                                             1120: Access of undefined property tile_index.

                     

                    Below is the code now:

                     

                    function tileIndex():void   //this must be wrong because it gives me that error code and as you predicted only gives one value (I want te whole lot times 3)

                                                {

                                                    for (var i: Number  =0; i < activeLevelofTilesArray.length*3; i++)

                                              {

                                                var tile_index = (i%activeLevelofTilesArray.length);

                                              }

                                                    }

                     

                                        function activeLevelofTiles():void

                                        {

                                            activeLevelofTilesArray = letterLevels.shift();

                     

                                            shuffleTiles(activeLevelofTilesArray);

                     

                                                tileTimer.start();

                                                trace(activeLevelofTilesArray);

                                                activeLevelofTilesArray[tile_index].x = 399;

                                                activeLevelofTilesArray[tile_index].y= 30;

                     

                                                addChild (activeLevelofTilesArray[tile_index]);  //maybe the addChild will work (issue 2) when the tile_index problem is solved

                                                trace("Letters should run");

                                                trace (activeLevelofTilesArray[tile_index]);

                                        }

                    • 7. Re: Movie clip not visible
                      Ned Murphy MVP

                      You are repeating your error from the other day, declaring a variable inside a function... it cannot be seen outside of that function.

                       

                      I do not see what purpose that tileIndex function serves at all.  If you are shuffling the array, there is probably no need to be randomly picking index values.

                       

                      Instead of worrying about getting 3 lots working, get one lot working first.  Once you accomplish that it should hopefully be easier for you to reason out how to repeat it (any number of times, not just 3).

                      • 8. Re: Movie clip not visible
                        Charine -FB buggoop Community Member

                        Hi Ned,

                         

                        I wrote the tile_Index function because of your comments in reply number 3. Maybe I understood you wrong?

                         

                        Right now I have changed the code again to have the var in the function it needs to be used (hope I understood you correctly there). I still successfully trace just the single object, but hope I will get it to repeat once I tie it to and event handler and the timer.

                         

                        My problem is that the single object created still does not show up in the swf - despite the addChild code. Other suff in this class like the word arrays does show. What am I doing wrong?

                         

                        Here is that code again:

                         

                        function initLetterTiles():void

                                            {

                                                for (var i: Number  =0; i < activeLevelofTilesArray.length*3; i++)

                                                {

                                                   var tile_index = (i%activeLevelofTilesArray.length);

                                                }

                                                    shuffle(activeLevelofTilesArray);

                                                     trace (activeLevelofTilesArray[tile_index]);

                                                     activeLevelofTilesArray[tile_index].x = 399;

                                                     activeLevelofTilesArray[tile_index].y= 30;

                                                     addChild(activeLevelofTilesArray[tile_index]);

                                                    trace("Letter Tiles should be running");

                                            }

                        • 9. Re: Movie clip not visible
                          Ned Murphy MVP

                          As I already mentioned, that loop is not going to do anything for you except end with one value of tile_index.  I also said you should not be declaring that variable in the loop. 

                           

                          See if the following does something more along the lines of what you are after...

                           

                          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;

                                            addChild(activeLevelofTilesArray[i]);

                                     }

                               }

                          }

                          • 10. Re: Movie clip not visible
                            Charine -FB buggoop Community Member

                            Hi Ned,

                            Thanks for the code above. The lettertiles trace correctly x 3 just as I want, but they still do not appear in the swf. After you click play, you can see the score and word appear, but no letter tiles falling from the log.

                             

                            These did show in the old swf when I hard coded one letter to test the mc's but now that it is in the right place, with the correct shuffle and loop coding it doesn't.

                             

                            I'm sure it is just a little piece of code I'm leaving out somewhere, but I have no idea where!

                             

                            Thanks for helping.

                            Charine