SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: for loop help

  1. #1
    SitePoint Zealot ralphnumbers's Avatar
    Join Date
    Nov 2003
    Location
    Saint Paul, Mn
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    for loop help

    I have nine movie clips (out1_mc,out2_mc...) that need to be invisible when loading the swf....
    So, instead of listing off ._visible = false for all of them I decided to make a loop. Unfortunately I am having issues...

    Here is what I have, which doesn't return an error. Any help with this would be much appreciated. Thanks!

    x=0;
    for(y=0;y<9;y++) {
    x+=1;
    var holder = "out"+x+"_mc";
    holder+"._visible = false";
    }

  2. #2
    SitePoint Guru krityx's Avatar
    Join Date
    Jan 2006
    Location
    Around
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    first of all you dont need x.
    you can also use eval(holder).
    Code Actionscript:
    for(y=1;y<=9;y++) {
        var holder = "out"+y+"_mc";
        this[holder]._visible = false;
    }


  3. #3
    SitePoint Zealot ralphnumbers's Avatar
    Join Date
    Nov 2003
    Location
    Saint Paul, Mn
    Posts
    129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    krityx,
    Thanks a lot. I'll give it a whirl this morning...

    Why is the this[...] necessary?

  4. #4
    SitePoint Guru Ize's Avatar
    Join Date
    Nov 2005
    Location
    The Netherlands
    Posts
    808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralphnumbers View Post
    krityx,
    Thanks a lot. I'll give it a whirl this morning...

    Why is the this[...] necessary?
    Movieclips are properties of their parent (which in this case is this).
    You can access properties of an object using that syntax.

    Code Actionscript:
    _root.foo_mc['_visible'] === _root.foo_mc._visible


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •