Buttons .. show/hide movieclips
New here and new to AS3 so wondering if any of you could assist with a little problem I'm facing.
Basically I have 3 buttons with 3 different movieclips, currently when I click a button it plays a particular movieclip.
The movieclip only dissappears if I click the same button again.
If I click one of the other buttons without clicking the first again it goes over the top of the other or under depending on which layer it is.
I've tried to make it so when I click one button the other movieclips are hidden but I've got to the point where I'm now cross-eyed and struggling to make sense of my code or logic :(
Any advice would be fantastic :)
your logic seems to be ok, however i don't totally understand your use of or need to use 'this.parent' , or you use or need to use 'MovieClip()'
make sure your file is set up correctly.
the best way to accomplish this is to have all your buttons, and the individual movieclips all on the first frame of a one frame main timeline.
another confusing part is you say that the buttons are directing the movieclips to play/be visible, yet you seem to be directing the main timeline to play ( (this.parent).play()' ).
don't instruct the maint timeline to play, tell the specific movieclips to play and act as you want them to.
here is a quick example that illustrates how this could work. to make it easiest to see in action, i separated the 3 movieclips that you would have one on top of each other. also, i am illustrating this using the 'alpha' property. you would of course best use the 'visible' property as per your code.
here is the complete code that makes it work. you will see that your code does seem to follow the same logic.
we could write this code more succintly, but instead i left it written out in 'long-hand'.
i hope this helps. if your project file is set up in a similar manner, then it should work for you as expected. if you need further clarification, please ask.
Wow .. thanks for the reply :)
I used the term 'this.parent' as the buttons are contained within a movieclip that is animated for 30 frames on the main timeline.
Tried your code and get a lot of 'Access to undefined property' errors but I'm guessing that is because the buttons are contained within a movieclip.
I will have another try tomorrow and place the buttons on the main timeline :)
Thanks again for such an in-depth reply that was very much appreciated :)
i usually like to pull back, and bring the concept down to its most basic elements, and first create a simple working example. once i am sure that it works, and that i understand the basics, then i can proceed to build upon it from that point and start adding more involved concepts. teasting at each stage, i figure out quickly what is not working for me and try to reolve it.
now of course i am not seeing your project, and i really don't understand from your descriptions what exactly is going on. if i did, i would love to help you more. but think of me as dense, and need to have everything spelled out:
there is a main timeline. is it one frame or is it a multi framed timeline with animations, frame labels, or what?
the buttons, where exactly are they? now i know they are inside another movieclip. that is fine - but are you saying that THAT movieclip has a 30 frame animation? so are the buttons on the first frame of that clip and are carried across the timeline, or do they show up in some 'future' frame? where are the other movieclips ( AE_frame, etc)? are they inside that same movieclip?
without some basic info like that, it is almost impossible to give any specific information. any code given code would be likely to turn up errors and function unpredictably, if at all.
here is a modified FLA of the sample i posted earlier. it shows the 3 movieclips on top of each other, and uses their 'visible' poroperty. maybe looking at its construction can help give you ideas on working on your project.
let us knmow how it goes