This content has been marked as final. Show 8 replies
you can iterate through everything but you can't limit the iteration to just dynamic text variables. what is it you're trying to do?
It's kind of complicated. Essentially I'm going to have a bunch of dynamic text fields, each of which will point to a different variable.
I want to do things like go through all those variables and set them to some value, without knowing before hand what those variable names are or how many there are.
It would be nice if I could start from the root, iterate through everything in my movie. If the object is a text object, then maybe I could look at what variable it is assigned to, and that would solve my problem...
I tried using typeof(), but when I do the for (i in _root) everything has a typeof string, so that doesn't help much....
that's correct. you cannot isolate text variables and you cannot isolate textfields with typeof().
but you could probably find an acceptable solution by using typeof() to check for objects and then check the html property of all objects and then check the text or htmlText property, as is appropriate, to effectively isolate all textfields. does that sound acceptable?
the link you posted also has a straight-forward solution because checking for a movieclip only returns movieclips (and references to movieclips.
Thanks, that sounds great...
The only problem is I'm still not sure how to iterate through movie clips or objects... when I iterate using for (i in _root) it's just all strings that get returned...
Thanks again for your help.
to iterate through all textfields on a given _level that have text assigned:
Great! That code helps me a lot.
There are still two weird issues.
1) the test for tl[obj].text seems to always turn out to be false. However, if I trace the value of text, I'll see the text.
trace(tl[obj].text); // This will display the value in the text field
if (tl[obj].text) // This is always returning false.
The 2nd issue might be more difficult - some of my text objects don't appear until later in the movie (i.e. frame 10). It sort of looks like this looping doesn't see objects that appear in the future. Do I need to advance the frame 1 by 1 and repeat this looping process until the text appears? Maybe instead I can always have the text in the first frame, but have it be invisible or something?
i can't recreate that problem with a textfield's text. if the text property is undefined or the textfield has no text, the boolean is false. otherwise, it's true.
post a link to a fla that contains a textfield with text and the boolean is false.
there is no work-around for the 2nd issue. if the objects don't exist when the code is executed, the code cannot detect the objects.