View Full Version : this. questions
Hello,
I have a simple question about "this".
I have seen code like this:
this["name"+i].theText.text = "text" + i;
How does the "this["name"+i]." part work? Can this be used as an array? I haven't seen any documentation about this. Where can I read about it or can someone explain?
Viggo
Fugee
06-05-2003, 11:31 AM
the [ ] are the mathematic eval method, they work like eval(); , more or less.
The line you mentioned works like this:
if the value of the variable named i was 1 (i = 1; ) then the script would result in this:
this.name1.theText.text = "text" + 1;
so this assigns to a text field named 'theText' placed inside an mc named 'name1' the text "text1"
Hope this helps you ;)
Fugee
06-05-2003, 11:44 AM
no problem ;)
Things to remember.
1) when evaluating 1 part of a path you put a . on the rhs but not the left i.e.
i=3
_root.path1.path2["path"+i].path4.path5._x =
_root.path1.path2.path3.path4.path5._x
2) when evaluating multiple parts of a paths do it in separate blocks
i.e
i=1; j=2;k=3;
_root["path"+i]["path"+j]["path"+k].path4.path5._x =
_root.path1.path2.path3.path4.path5._x
3) when evaluating for objects on the same time line start with a this
i.e. this["path"+1] =
path1 or this.path1 or _root.path1 if we are on the root
["path"+1] on its own will become the string "path1"
fgf
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.