Skip navigation
Currently Being Moderated

Make movieclip invisible

May 10, 2011 12:51 PM

Can someone give me a code example of how I would make my movieclip called 'back1' invisible?

I tried

back1.visible = false;


and got the message in the compiler that this isn't supported in AS3

  • Currently Being Moderated
    May 10, 2011 3:03 PM   in reply to MayerReed

    That code is fine.  Where did you place the code?  What is the complete error message?

    Mark as:
  • Currently Being Moderated
    May 10, 2011 4:09 PM   in reply to MayerReed

    You only need to have the line: back1.visible = false;


    An ENTER_FRAME event is not what its name suggests.  What it does is it fires at the frame rate of the file, as if it was continuously entering a frame.  It has nothing to do with actually entering that frame. So just having that line by itself is sufficient to make it happen in that frame.


    As for the error, how is that name assigned to the movieclip B?  It should be assigned to the movieclip via entering that name in the Properties panel field shown as <Instance Name> when you select it on the stage.  And that movieclip also needs to exist in frame 1 in order for it to be targeted by that code.  I would have expected a different error though if mis-naming or non-presence is the issue

    Mark as:
  • Currently Being Moderated
    May 10, 2011 4:45 PM   in reply to MayerReed

    Yes, that listener/handler wouldn't be causing the error, but is not needed for what you were doing.


    Is that the entire error message?  If you comment out that line do you still get the error?


    Can you show a screenshot that includes that movieclip, the timeline, the properties panel and the actionscript (It'll be large)


    Also, before you test the file again, go into your Flash Publish Settings and select the option to Permit Debugging.  That might add some info to the error message.

    Mark as:
  • Currently Being Moderated
    May 11, 2011 12:57 AM   in reply to MayerReed

    For what I understand you need to direct the comand to make back1 visible, to parent. That is, your back1 and movieclip C are in the same level, and want to call back1 inside moviclip C, so you need to tell C where back1 is.


    Inside C, try something like:



    I usually don't code in timeline, but I would keep every code inside the frame and not in the objects itself. May result in bigger difficulties if you want to debug something.


    See if this helps.


    Mark as:
  • Currently Being Moderated
    May 11, 2011 12:43 PM   in reply to MayerReed

    Yes there is


    But you have to plan a bit ahead of what you're going to do. I only use root or parent in the infimous last resort. For one side, this may confuse you if you end the project and want to get back later on. Probably you have forgotten how everything was organized, and you will spent too much time just to figure what is the parent or the root... they have no names.

    Last I've always read that everytime this is possible don't use, it's considered bad practice, probably by the reason I stated earlier, or even others.


    For example you have a MovieClip A and inside it a MovieClip B. if you want to call a method of B from A, well it's easy mvB.methodToCall(), right?


    But consider this. You want to remove B with a button that is inside B. You can't, because the compiler will tell you that, the child must be removed from the parent, i.e., from B you have to remove it from A.


    Two options: whether you remove with a parent call, or you can do it wil a function callback.


    This last option is what I always do, with no trouble at all. Basically when you instantiate B, one of the arguments will be a method name, that exists in A... say deleteB(). When you press the button in B to delete it, B will call this function, that it knows it's in A, then the A removes B.


    It's simpler than it sounds.


    Visit this blog entry, that has an example of how to do it.


    Try with a basic example justo test it, and then move to your project.


    I think it's very clear, but be free to ask.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points