1 Reply Latest reply on Oct 14, 2009 5:21 AM by Ned Murphy

    how can i trace() the length of an array outside the onLoad()

    cosmicvibs Level 1

      Hello evryone, I have a question i need to get the length of an array but outside the onLoad()

       

      here is my code:

       

      var O:XML = new XML();
      O.ignoreWhite = true;
      O.onLoad = function(success) {

       

          var photos:Array = this.firstChild.childNodes;
          _root.PanelH = photos.length*200;
          trace(PanelH);
      };
      trace(PanelH);
      O.load("VideosBank.xml");

       

      i shure is possible but i dont find

        • 1. Re: how can i trace() the length of an array outside the onLoad()
          Ned Murphy Adobe Community Professional & MVP

          If the array you are talking about is the photos array, then to be able to access it from outside the function you need to declare it outside the function.

           

          var photos:Array;

           

          O.onLoad = function(success) {

           

              photos = this.firstChild.childNodes;
              _root.PanelH = photos.length*200;
              trace(PanelH);
          };

           

          You will not be able to trace anything meaningful of the lngth until after the onLoad function has filled the array though.