Skip to main content
May 21, 2007
Answered

assigning visibility to a variable movie clip name

  • May 21, 2007
  • 9 replies
  • 515 views
Hello,

I'm having a problem with this code. I'm working on tempPath3 which is a variable that contains a movie clip that I want to turn on. The variable contains the explicit path to the movie clip, and I think that might be the issue. I traced the output of the variable, and it looks like it is named correctly, and I did "hard coded" test where I just entered some of the movie clip names by hand and they worked great. I can't seem to find where the rub is on this one. Anyone have any ideas? If so they would be greatly appreciated.

Thanks!

Steve
This topic has been closed for replies.
Correct answer kglad
try:

9 replies

kglad
Community Expert
Community Expert
May 22, 2007
you're welcome.
kglad
Community Expert
Community Expert
May 22, 2007
a little more precisely: ivar is property assigned to each of your mainmenu movieclips that makes it easy for those movieclips to determine their own "i" value.

you could also use their _name property and the flash string methods to extract that i value, but it's easier to just assign a property to each movieclip.

this property can be retrieved any time. in particular, when one of your mainmenu movieclips are clicked, it's now easy to make _visible the appropriate mainmenuX_clicked and submenuX movieclips.
May 22, 2007
Incredible.

Thanks!
Steve
May 21, 2007
I beleive so, yes.
kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 22, 2007
try:

May 22, 2007
Oh my lord, that works like a dream! Thank you so much! Let me see if I understand what it is here that is going on. Basically you created an object for the two clips called ".ivar" that is re- assigned the for loop is iterated. So this is actually stored in the clip object, and not as an external variable, so when this.ivar is called later, it knows the variable can be called.

What I don't get is why _root.main cannot be stored in the variable, but that is obviously where the rub is, and this technique you did circumvents that issue.

Thank you very much for your help. I appreciate it greatly!

Steve
kglad
Community Expert
Community Expert
May 21, 2007
menuItemMC is the sibling of _root.main["submenu"+X]? so, clip=main?
May 21, 2007
My apologies, yes you are correct, mainmenuX is not the parent of _root.main["submenu"+X]. It is a sibling as well. In the XML structure (which I am using to populate the menus), it is a parent, but not the flash structure.

menuItemMC does not contain any child movie clips. It is basically a colored rectangle, with a dynamic text field. The way the actionscript works, an empty clip is created and instances of menuRolloverItemMC is placed in that empty clip dynamically populating the menu items.

menuRolloverItemMC does not contain any children either, it is basically a twin of menuItemMC, with a background image at 0% opacity.

I hope that helps. I'm feeling like a nitwit.

Steve
kglad
Community Expert
Community Expert
May 21, 2007
mainmenuX is not the parent of _root.main["submenu"+X].

does menuItemMC contain a child movieclip name "submenu"? does it contain several submenu movieclips like submenu1, submenu2 etc?

does menuRolloverItemMC contain any child movieclips that are relevant?

May 21, 2007
mainmenuX is the parent of _root.main["submenu"+X].

mainmenuX_clicked is a sibling of mainmenu and exists on a lower level to appear behind mainmenuX.

Three things happen when mainmenuX is released.

1. A loop statement assigns false to the visibility for all "submenu" and "mainmenuX_clicked" clips.

2. _root.main["submenu"+X] becomes visible.

3. mainmenuX_clicked becomes visible.

That the basic jist of it.

Steve
kglad
Community Expert
Community Expert
May 21, 2007
what is the relationship between _root.main["submenu"+X] and mainmenuX and or mainmenuX_clicked?
kglad
Community Expert
Community Expert
May 21, 2007
tempPath3 can't possibly be a movieclip reference. it doesn't even look like a movieclip reference. if you used:

tempPath3 = [this + "._clicked"];

that would, at least, look like a movieclip reference, though it's not.

if the movieclip has instance name _clicked and it's on the timeline that contains your code use:

this["_clicked"];

or

this._clicked;
May 21, 2007
Hi kglad,

Thanks for your responce. I added some more code for you to look at. Let explain what it is that I am trying to do a little more. I basically want a dynamically created button, that when clicked shows an image, until another button of it heirarchy is clicked. The way I figured I would do this is to create two movie clips. The first would have rollover and on release functionality, and the second's visibility would be controlled by the first. I hope that makes sense. That may be a wonky way of trying to accomplish the effect, but it was all I could think of. What are your thoughts? Thanks for replying!

Steve