|
-
Dynamic reference names in CS3?
I'm trying to make a new reference object like
for(x = 0 to yadda yadda) {
_root['hi'+x] = reference;
}
the _root[] and this[var+asdf] don't seem to be working anymore in CS3. How you name dynamic references?
-
Senior Member
You may want to use the name property:
this[h+i].name = "h"+i;
then later you get the child by using:
getChildByName("h5);
- The right of the People to create Flash movies shall not be infringed. -
-
a.k.a gltovar
something else to consider is discussed in this topic:
http://board.flashkit.com/board/showthread.php?t=740388
= ]
-
I'm talking about examples that don't warrent the use of arrays. I also can't get this[] to work in the situation I'm using, for example,
reference.this['customname' + x] doesn't work
If there's a dot in front of this it fails. Also, It doesn't seem to be working if I have the word var in front of it, is var implied automatically when you do this[customname]? If so, how can you reference it again? Wouldn't writing this[customname] reinstantiate it?
-
'this' stands for the object the currently running function belongs to. Things like "var this" and "reference.this" make no sense. Or, rather, they would be trying to declare a variable named "this" that is distinct from the implicit "this" which is forbidden.
this['somename'] is equivalent to this.somename, except that the somename part can be constructed on the fly. Once you have set this['someproperty'] to some value, you have actually stored that value in the someproperty field of the current object. Referencing it later is as easy as using this['someproperty'] again.
-
The current example I'm working with is that I'm getting flashvars along the order of
var1=this&var2=that&var3=theotherthing
so in my SWF I want to do
for(var x = 0; x < 10; x++) {
this['var'+x] = root.loaderInfo.parameters.this['var'+x];
}
instead of
var1 = root.loaderInfo.parameters.var1;
var2 = root.loaderInfo.parameters.var2;
...etc
But as I said making a dynamic reference there doesn't work with this.
-
a.k.a gltovar
reference.this['customname' + x] doesn't work
something like that would work like:
reference['customname' + x ] would be the way out do that ( i think)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|