A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Dynamic reference names in CS3?

  1. #1
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273

    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?

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    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. -

  3. #3
    a.k.a gltovar deadlock32's Avatar
    Join Date
    May 2001
    Location
    Naperville,IL
    Posts
    489
    something else to consider is discussed in this topic:

    http://board.flashkit.com/board/showthread.php?t=740388

    = ]

  4. #4
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273
    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?

  5. #5
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    '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.

  6. #6
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273
    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.

  7. #7
    a.k.a gltovar deadlock32's Avatar
    Join Date
    May 2001
    Location
    Naperville,IL
    Posts
    489
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center