I have a menu button. When this button is pressed the drop down menu appears. The whole actual functioning menu works great as it is fairly simple to create, but what I can't get to work is a button within the menu that drops down.
I first saw this example in a flash movie I downloaded here and have attempted to basically recreate it, except to not use action script on the buttons themselves, but rather from the main time line for good coding practice.
I attached a REALLY simple version of this. As you can see pressing the green button after the menu appears does nothing instead of tracing "works".
use movieclips for buttons, its easier :P i NEVER EVER use buttons, thats just my own preferance though anyway to the point, if you have a button inside a movieclip(i dont know if it works with a button inside a button) then your not typing just that buttons instance name, you need to type the movieclips aswel, im sure thats how it works anyway so
mcmenu is the movieclip with the button in (movieclips instance name)
btn1 is the button inside the movieclip (buttons instance name)
mcmenu.btn1.onPress = function() {
//whatever the script does
}
Thanks for the reply Milna, but that is exactly what I have done if you viewed the file. I never use the actual button symbol. The actionscript you posted is the exact same I have on my main timeline for the inside button (movieclip instance) I have created.
I have done more in depth button usages and I can't figure out why this doesn't work. This isn't a issue with the visible function either in the AS because I have tried switching to having the menu slide down into the main movie with masks and have tried using a fading / incrementing alpha. I simply used the visible property here to prove the point that I can't get a (movie instance) button to work inside another.
hmm, the outer MC will be over powering the inner MC, put MOUSE ROLLOVER function on the outer mc to bring the menu up and use onPress function or whatever on the button inside the menu but youll also need the rollover function on the other buttons in the menu aswel, so
Code:
menu1.onRollOver = function() {
//script that opens menu here
}
menu1.innerbtn1.onRollOver = function() {
//script that opens menu here
}
menu1.onRollOut = function() {
//script that closes menu here
}
menu1.innerbtn1.onRelease = function() {
//whatever the btn does
}
thats from the top of my head, might not work, but youll get it after youve read it
menu1 is the menu mc
innerbtn1 is the mc in the menu mc
Like you, I'm confused by this problem, and I don't really have an explanation or solution for you. I have worked a few things out, however, which may help you.
which is the problem. If you comment that out, the rest of it works exactly how it should. I haven't the faintest idea why this would be. Of course, this leaves you with the problem of how to make the drop down go away afterwards.
Nothing I tried really worked, so I put together a little work around of having the dropdown disappearing on the rollover of an invisble button that surrounds the main button and the menu. Doubtless there would be a better way of doing this, but unfortunately you'd have to find someone more pro than me to tell you how :O
I've attached my little work around, hopefully this helps or at least gives you some ideas. If you ever sort this out properly do post the solution, because I for one would be keen to hear what the problem is.
Ah, just realised that I attached a CS4 version of the file. Here it is in CS3, that's the oldest version I can make it so hopefully you are able to open it.
Sorry Ribbibarnes I can't view CS3+ because I have flash 8. I tried your solution milna93, but I'm still having the issue of the top movieclip not being recognized as "on top". It seems as though anything that moves cannot have an inner btn, but I have seen this before its nothing special. Just can't figure it out.
I managed to make a version for Flash 8 - my colleague is still running CS3, so we can work our way back.
Do give it a go and see if it works for you, if not I could describe what I mean in more detail. The key point is that is you comment out the bit of code I mentioned before, the other code works, so at least that may give you a place to start trying to work it out.
Thanks Rickibarnes, the workaround will have to do for now, but I find it so strange that by adding the onRollOver event causes the movie referenced to be brought to the top or mix up the level of the movies within.