Skip to main content
Participating Frequently
September 27, 2006
Question

animated drop-down menu buttons won't respond onRelease

  • September 27, 2006
  • 9 replies
  • 510 views
I created a drop-down menu movie clip. Within it are multiple buttons which change their alpha values. I'm having an impossible time of getting the buttons to respond to an onRelease from the maintimeline.

for instance:

stop();
_root.menu_mc.print_btn.onRelease = function(){
gotoAndStop("print1");
}
_root.menu_mc.illustration_btn.onRelease = function(){
gotoAndStop("illustration1");
}

I can't place any code directly on the buttons because later in the timeline the actionscript needs to change for the same buttons:

stop();
_root.menu_mc.print_btn.onRelease = function(){
gotoAndStop("print2");
}
_root.menu_mc.illustration_btn.onRelease = function(){
gotoAndStop("illustration2");
}
This topic has been closed for replies.

9 replies

kglad
Community Expert
Community Expert
September 28, 2006
you're welcome.
Participating Frequently
September 28, 2006
actually all the code will be located only on the five buttons within the menu_mc. it won't be scattered everywhere.
thanks for the input, but things seem to be working fine.
kglad
Community Expert
Community Expert
September 27, 2006
your basic approach is problematic. having code in different parts of your swf is undesirable as you already realize.

you generally want to place your code in a limited number of locations so it's easy to develop your project, debug it and extend it.

a better way to handle this issue is to insure that all objects exist on the first frame of menu_mc. they need not be visible (you can use the _visible property).
Participating Frequently
September 27, 2006
wait, i screwed up. I got it to work.
if there's a way to use this method for changing the script dependent on where the user is, i'll use it. But it seems an if/else might be easier.
Participating Frequently
September 27, 2006
ok, i understand now that the mouse handlers don't exist until after frame 9 when the buttons are actually able to come up.
I did try attaching the code to 28 of the menu_mc timeline, but nothing happens.

Also, i don't see this as a solution even if it was working. I need to be able to change the actionscript dependent on where the user is in the timeline, and i can't overwrite it within one movieclip.

However, I think i found a way to do it through IF/ELSE statements placed on the individual buttons.

Thank you very much regardless!!! I really appreciate it!
Participating Frequently
September 27, 2006
each button does have the same instance name, but it's the same button set at a different alpha.
Participating Frequently
September 27, 2006
Do you want to look at the file?
http://download.yousendit.com/1153BBE82D48F87B

The dropdown is activated by a hidden button.

Maybe it's the instance name?
kglad
Community Expert
Community Expert
September 27, 2006
your mouse handlers are defined for objects that don't exist (yet). it's not until main_mc plays beyond frame 9 of its timeline that your buttons exist.

to remedy you can attach your code to frame 28 of menu_mc's timeline. be sure to change your goto functions to goto methods of the _root timeline:

kglad
Community Expert
Community Expert
September 27, 2006
how's the dropdown work then?

and what do you mean by, "If I place a button instance inside of menu_mc (and there are not multiple instances of it) I can use an onRelease and it works fine."?

having more than one instance of an object would cause no problem. having more than one instance of an object with the same instance name would be a problem. is that the issue?
kglad
Community Expert
Community Expert
September 27, 2006
are there mouse handlers attached to _root.menu_mc? if so, they are interecepting the mouse events and the child movieclips cannot respond.
Participating Frequently
September 27, 2006
i don't think so. Sorry for my ignorance, but the code you see is basically the only code I have in the movie.
menu_mc is located directly on the maintime line. Inside of menu_mc are the buttons. If I place a button instance inside of menu_mc (and there are not multiple instances of it) I can use an onRelease and it works fine.

I can create an invisible button, place it over the animated button and get the onRelease to work, however, since the buttons are rollovers, I loose the animation with the invisible button covering them up. I can't seem to target multiple instances of the same button in the movieclip. is there any way around this?