View Full Version : Button over state with movie clip
danny
08-19-2003, 03:29 PM
Hey all, wondering if somebody could give me a tip here.
I've got a Flash file that has several buttons and movie clips in it that make a drop down menu [see URL below].
I want to make the main buttons over state to remain over [yellow] while the user is on the submenu, but they're two separate symbols. How can I do this?
http://home.earthlink.net/~dmiller76/flash/DropDownMenu.html
sendres
08-20-2003, 01:05 PM
Let's see if we can get this thread started for ya...
It's a bit tough to say without seeing your source file. I'm guessing that the top bar consists of buttons and the drop downs consist of movie clips. I say that because it seems like the menus sometimes fail to collapse when you roll from one menu to another.
I'm working on something similar right now. My solution was to have the top buttons as movie clips. You might try the same:
Create a movie clip of the "yellow state" of the button.
Create another movie clip with the following:
- a bottom layer with the "blue state" of the button
- a middle layer, which we'll discuss in a second
- a top layer for your text.
Now, for that middle layer. Place an instance of the "yellow state" movie clip on the stage, aligned with the bottom layer. Give it a sensible instance name like "yellow". Now you can set and reset the state of the button using ActionScript:
this.yellow_visible = false;
this.onRollOver = function ()
{
this.yellow._visible = true;
// make the submenu here
};
Hope this helps...
sendres
08-20-2003, 01:07 PM
the first line of ActionScript should be
this.yellow._visible = false;
I forgot a '.'
danny
08-20-2003, 03:10 PM
Thanks for your reply. You are correct in that the main, top buttons are movie clips which contain buttons for the buttons and movie clips of the drop down submenu buttons. Invisible graphic symbols are placed all around the main button and expanded submenu which trigger the submenu to "hide".
I think I mostly understand what you suggested; let me give it a shot. In the meantime, is there a better way for me to do this type of drop down menu? I know the tutorial on this site is slightly different. Thanks.
danny
08-20-2003, 04:04 PM
Okay, I need clarification on something.
Should the blue button mc, containing the yellow button symbol, also contain the submenu mc? Or should the submenu mc reside outside/at the same level as the blue button mc?
And what does "// make the submenu here" mean?
Thanks.
sendres
08-20-2003, 06:06 PM
First, in my whopping one month of experience, it depends on what's easier within the framework of what you've done so far. I'd say you want to keep the main movie clip and the submenu clip separate. That way you can control one (i.e. roll down the submenu) without affecting the other.
Second, the "// make the submenu here" is a comment. A comment is text that you add to your source code to help a human being read it. Starting a line with "//" tells ActionScript (and also Java, C++, and other languages) to ignore everything from the "//" to the end of the line. Flash won't try to evaluate the comment; it's just for humans:
// a comment before a line of code
myButton._x = 25;
myButton._y = 50; // a comment can also finish a line of code
Finally, the yellow doesn't have to be a button symbol. Buttons are nice because they have these four built-in states (up, over, down, and hit), but movie clips are frequently more useful because a movie clip has its own timeline. I'm going to guess that you're writing your ActionScript to roll down the submenu on the over frame of the button, which will work just fine. But you can also attach a rollOver to a movie clip, and it has the same effect as a button state:
// create a new button
this.attachMovie ("mc_main_button", myButton, 1);
this[myButton].onRollOver = function ()
{
// commands to roll down the submenu go here
};
The above script takes the mc_main_button symbol from the library and creates an instance of the symbol on level 1 of the stage named myButton. It then sets up a function, telling Flash what to do when the mouse rolls over the movie clip.
If you'd like, post some code or a zipped .fla, and I'll try to help some more.
Good luck!
danny
08-21-2003, 03:13 PM
Well, you obviously know more than I do in your one month. Thanks for the explanation.
I'm going to give it a try and will see if I can get it to work.
danny
08-21-2003, 05:53 PM
Well, I gave it a try. [I removed the other 3 menu items just to clear things up until I got one working right.] Here's the new file:
http://home.earthlink.net/~dmiller76/flash/DropDownMenu3.html
It's working half right; the wrong half is that the submenu doesn't stay expanded because of the onRollOut event on the yellow button. Here's the source:
Scene 1
menu 1, (about_us)
Symbol Definition(s)
menu 1
menu 1 gold
ABOUT US, (Kryski, 12 pts)
menu 1 gold
actions for menu 1 gold
on (rollOut) {
gotoAndPlay (11);
}
ABOUT US, (Kryski, 12 pts)
menu 1 blue
actions for menu 1 blue
on (rollOver) {
gotoAndPlay (2);
}
ABOUT US, (Kryski, 12 pts)
submenu 1
submenu 1
submenu 1
actions for frame 1
stop ();
actions for frame 10
stop ();
menu 1 gold
menu 1 blue
submenu 1
COMPANY HISTORYOUR NEW LOCATIONCOACHES & STAFFCALENDAR OF EVENTSCONTACT US, (Verdana, 9 pts)
submenu button 1
submenu button 1
submenu button 1
submenu button 1
submenu button 1
submenu button 1
Any clues?
sendres
08-21-2003, 06:10 PM
What I did is not use the onRollOut Event. Try changing your main movie clip onRollOver event to first roll up the extended submenu (if any) before it extends the new one.
I can't really make sense of your code without seeing the whole way the timeline and graphics are structured. So it's kinda tough to comment further. Maybe post your .fla or emil it to me and I'll look further.
Break a leg...
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.