A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: simple array will not hide MC's on stage

  1. #1
    Member
    Join Date
    Apr 2014
    Posts
    63

    simple array will not hide MC's on stage

    I have three MC's on stage with instance name mc1, mc2, and mc3. Why would this not hide them:

    code:

    var members:Array = new Array("mc1", "mc2", "mc3");

    for (var i = 0; i<members.length; i++) {
    members[i].visible = false
    }




    I did a search online and someone had the problem. The person recommended for them to do the above and they said it worked. Although I don't know why mine won't.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Either of these will do what you require

    this[members[i]].visible = false;

    or

    root[members[i]].visible = false;

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    members is an array of strings - text. "mc1" is a string, not a movieclip. So you can't make a string invisible.

    fruitbeard is showing you how to use the string to reference a movieclip's name.

  4. #4
    Member
    Join Date
    Apr 2014
    Posts
    63
    I did the above but did not work ... here is the error it gives:

    Scene 1, Layer 'Layer 2', Frame 1, Line 6 1084: Syntax error: expecting identifier before leftbracket.
    Scene 1, Layer 'Layer 2', Frame 1, Line 5 1084: Syntax error: expecting identifier before rightbracket.

    I tried it as

    this.(members[i]).visible = false;

    But this did not work either.

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Perhaps you should attach your *.fla as it is probably coming from some other code!!!

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,404
    Quote Originally Posted by fruitbeard View Post
    Hi,

    Perhaps you should attach your *.fla as it is probably coming from some other code!!!

    lmao. this

  7. #7
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Try this, i don't know :P :

    PHP Code:
    var members:Array = new Array("mc1""mc2""mc3");



    for (var 
    0members.lengthi++) 
    {
     var 
    mc:MovieClip MovieClip(members[i]);
     
    mc.visible false

    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  8. #8
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    I believe the poster got it sorted over at as.org, it was a case of human error.

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