PDA

View Full Version : n00b misery addressing MovieClips



jeefr
June 8th, 2008, 03:01 PM
I'm trying to create a programmable display effect in which I control bunches of MovieClips nested in other MovieClips to display various combinations of seven letters in varying degrees of visual distress.

Using "dot" notation I can do what I need to by brute force, listing each and every one of them by using the instance name given to each letter's position, like so:

Letter0.Aon1.alpha = 0;
Letter0.Aon2.alpha = 0;
Letter0.Bon1.alpha = 0;
Letter0.Bon2.alpha = 0;
...Letter6.Zon2.alpha = 0;The nested clips go another level deeper, like so:

Letter0.Aon1.wide4
Letter0.Aon1.wide8
...As you can see, I tried to name the nested clips so it would be straightforward to address them programmatically. BUT, I am failing in my efforts to assemble strings and then change some property or another in the nested mc's .

In a more perfect world I would be able to create Arrays-lists of clips/Sprites to act upon and then iterate through the arrays merrily creating new Sprites and tweening changes as I go. That's kinda the point, right? :stare:

Can someone point me to a tutorial on the basics of dynamically constructing references to MovieClips or Sprites and then using them to change their properties? How does a string become a working reference to an existing MovieClip/Sprite?


TIA

Krilnon
June 8th, 2008, 04:49 PM
Well, I doubt you'll find an entire tutorial on the subject, but you can always access object properties using the array access operator:


Letter0['Aon1']['wide4']

You could access Letter0 using a string as long as you have a reference to an object that holds a reference to it. Usually, people use this to access the first member, but of course the appropriateness of using this depends on your actual code.

jeefr
June 8th, 2008, 08:00 PM
... ahh, objects ARE arrays, at least in a manner of speaking. I never, ever, woulda figgered this one out using Adobe's docs.

THANK YOU!

jeefr
June 8th, 2008, 08:18 PM
... more precisely, objects behave like Associative Arrays and the Display List itself is an humongous, kludged-up Associative Array! ...or something like that...

I don't know whether to be amazed, appalled, annoyed, or deeply humbled. Apparently the deeper one dives into programming, the further one leaves behind "real world" metaphors to explain how things work....