4 Replies Latest reply on Jun 27, 2006 12:15 AM by NoNameNoPackDrill

    Define, initialise, populate arrays

    NoNameNoPackDrill Level 1
      There have been a few posts on this topic, but none I can fine presents a complete fix - so let me set out my problem and hope...

      I need to initialise a set of arrays that will be used to hold coordinates - there will be about 100 that I want to populate with text when the Flash loads - so:- I thought I would set up a loop to define the required array names, created them and populate then all in one go - well that's what I thought...

      I can define variable that trace the correct Array names on the screen, but when I reference these to push text into them, I get nowhere.

      Here's my loop:-

      - I attached the code snippet...

      No errors reported, but no data created either...
        • 1. Re: Define, initialise, populate arrays
          NoNameNoPackDrill Level 1
          OK - the deafening silence tells me I'm trying to do something stupid...

          Suppose I declare the arrays up front, then only need to use my loop to populate them, would that work...

          I'll give it a try...
          • 2. Re: Define, initialise, populate arrays
            injpix Level 3
            Hmmm…you have some data types mixed up in that code. I am not completely sure what it is that you are trying to do. Does this file that you are loading have variables (coordinates) in it? Also are trying to list all of the coordinates in one textfield? I don’t see in your code where a textfield plays a part unless you are trying to trace an output. I would recommend using a XML file just because it is easier to pull data using ActionScript. Reply with more details.
            • 3. Re: Define, initialise, populate arrays
              Level 7
              > for (arrayNum=0; arrayNum<99; arrayNum++) {
              > arrayName = ["inl"+arrayNum];

              What are you trying to do above? ... you have set arrayName to be an array
              with a single string in it. That seems very odd. There is no need for the
              [ ] here (in fact, it can screw things up).

              > aid.load(fileName); //Read the text file
              > aid.onLoad = function() {

              you should set up the onLoad before you call load()

              > "inl"+arrayNum = myTempArray2; //This should now be a two dim'
              > array of coords...

              That line makes absolutely no sense .. you are assigning a value to
              arrayNum
              , and then adding the string "inl" to the front of the result and
              doing nothing with the answer.
              --
              Jeckyl


              • 4. Re: Define, initialise, populate arrays
                NoNameNoPackDrill Level 1


                OK - I admit it; that code snippet is a bit of a mess - but, in my own defence - it is the result of half a day of screwing around and trying all sorts of anything to make it work - so, having slept on it and had a chance to reflect - I think I'll go back to square one, then take another step backwards and start again.

                FWIW - all I wanted to do was create an indirect reference to a number of arrays in a number of groups, each containing a set of coordinates. I need these, about 100 as I said, so I thought it would be a breeze to set up a loop to initialize them when my project loads - rather than have to code each initialization in turn - however, I have now wasted more time than it would ever have taken to hand code this blindfolded, with both hands tied behind my back!

                Onward and upwards

                Thanks anyway

                Nigel