This content has been marked as final. Show 6 replies
> 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:
> //where the "1" is replaced with an index
> To function the same way as:
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]);
Good idea, thanks! Still, I want to know this concatenating stuff. Anyone seen anything on this?
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:
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?
[..] 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"]
Fantastic! Thanks so much. :)