6 Replies Latest reply on Mar 1, 2007 10:54 AM by aniebel

    Concatenating problem

    aniebel Level 2
      Can anyone suggest a good resource for learning all the rules of concatenating in AS 2.0? I did a quick search online and here but there are tons to sift through. I'd really like to "get" this.

      I keep running into problems in my projects with this and try things several different ways but usually just end up staring at the monitor and scratching my head. For instance, right now...

      Can't get this:
      picHolder_mc.loadMovie(PICPATH+"aIns"+i+[yearIndex][currentIndex]); //where the "1" is replaced with an index

      To function the same way as:
      picHolder_mc.loadMovie(PICPATH+aIns1[yearIndex][currentIndex]);
        • 1. Re: Concatenating problem
          Level 7
          aniebel wrote:
          > Can anyone suggest a good resource for learning all the rules of
          > concatenating in AS 2.0? I did a quick search online and here but
          > there are tons to sift through. I'd really like to "get" this.
          >
          > I keep running into problems in my projects with this and try things
          > several different ways but usually just end up staring at the monitor
          > and scratching my head. For instance, right now...
          >
          > Can't get this:
          > picHolder_mc.loadMovie(PICPATH+"aIns"+i+[yearIndex][currentIndex]);
          > //where the "1" is replaced with an index
          >
          > To function the same way as:
          > picHolder_mc.loadMovie(PICPATH+aIns1[yearIndex][currentIndex]);

          Can't you have alns as the array instead of alns1, alns2, etc? Then you'd
          use it like
          picHolder_mc.loadMovie(PICPATH+aIns[ i ][yearIndex][currentIndex]);

          Andrew


          • 2. Re: Concatenating problem
            aniebel Level 2
            Good idea, thanks! Still, I want to know this concatenating stuff. Anyone seen anything on this?
            • 3. Re: Concatenating problem
              tonyhigham Level 1
              Looks to me like you pretty much have the idea down. Andrew's solution works fine, and I think if you modified your original code as follows, it would also have worked:

              picHolder_mc.loadMovie(PICPATH+["aIns"+i][yearIndex][currentIndex])
              • 4. Re: Concatenating problem
                aniebel Level 2
                Thanks Tony, I'll give that a shot. But what I don't get is what or why do you put the array access operator around ["aIns"+i] ?

                I understand why to use it when referring to arrays but how does one decide what it should encase? Does that make sense?
                • 5. Re: Concatenating problem
                  tonyhigham Level 1
                  [..] is actually not an array access operator, but more of an object resolver. When you say it resolves the array object by that name. The same thing works for other objects, like movieclips. For instance, if you have a movieclip on the root timeline named myMovie12, you could access its properties, callbacks, and functions like so:

                  _root["myMovie" + 12]._x

                  _root["myMovie" + 12].myFunction(myArg)

                  _root["myMovie" + 12].onRelease()

                  So the moral of the story is that your concatenation was fine, you just werent resolving the object properly. An array is just a special kind of object, and you want to access another object 2 tiers into it. You can always use brackets to dynamically resolve objects based on strings.
                  You could even do this:
                  ["_roo" + "t"]["myMovie" + 12]["_x"]

                  :)
                  • 6. Re: Concatenating problem
                    aniebel Level 2
                    Fantastic! Thanks so much. :)