View Full Version : Menu Appears on Mouse Hover
itsthejohnes
07-07-2004, 07:53 PM
Whats the easiest way for a simple text-based navigation menu to appear when the mouse hovers over an image?
Crismo
07-08-2004, 05:20 AM
In HTML use the onMouseOver event to show the menu, and the onMouseOut (with a time delay) to hide it.
In Flash you could put the image inside a MC and do the same with the onRollOver and onRollOut events.
itsthejohnes
07-08-2004, 07:42 PM
If I use "onRollOver"
What goes in the parentheses of the onRollover function?
like:
onRollOver(?????????)
{
}
Crismo
07-09-2004, 05:34 AM
Hehe. You’re not giving me much information to work with. ;)
You are doing this in flash. The answer to your question then, is that it should contain the code for menu visibility, placement, animation, duration etc.
It’s all basic manipulation of the MC built inn class object.
Say your button (the picture) is called my_button, and the menu is called my_menu.
Then a simple solution would be something like this:
// Start of the movie, hide the menu
my_menu._visible = false;
my_button.onRollOver = function()
{
// Show the menu
my_menu._visible = true;
// Place the meny
my_menu._x = this._x;
my_menu._y = this._y + 20;
}
You kind of have to make a mental picture of what you want to happen. Then look at the variables and objects at your disposal, and if they are not enough, combine them with some god old animation etc.
For instance, instead of just making the menu visible, you could fade it in by gradually incrementing the menus alpha property.
For extra effects etc masks can be a great tool.
itsthejohnes
07-09-2004, 04:25 PM
Thanks alot for your help, I really appreciate that.
Here is what I am trying to do. I have a bitmap image as a background, not doing anything special with that. Around that graphic, I have movieclips that fade in and out when you hover over them (which I got off actionscript.org). I also have a movieclip that is an animated menu. Now, what I am trying to do is, once you click once on the fading image movieclip, the animated menu movieclip appears, and you click on the fading image once more, it goes away. Ideally, however, I would like the menu movieclip to fade in/out, rather than just appear out of nowhere.
I can figureout how the concept works logically (I know alot of C Programming), but the hard part is converting the thoughts in my head to action script.
Attached is the action script code that controls the image fade in/out, which is where, I presume, the code to respond to the image click will go as well.
onClipEvent(load)
{
dir = 0;
speed = 6;
original._alpha = 0
this.onRollOver = function()
{
dir = 1;
}
this.onRollOut = function()
{
dir = -1;
}
useHandCursor = false;
}
onClipEvent(enterFrame)
{
temp = original._alpha + speed*dir;
original._alpha = Math.min(100,Math.max(temp,0));
}
Crismo
07-09-2004, 06:54 PM
Hey I’m a C programmer, well actually C++. But anyway I had the hardest time with Flash, timeline, AS stuff when I started looking into it.
But now I have lost the structure and logic skills my college professors used years to teach me. And so I speak AS instead.
No just kidding, still love and work with C, Java and all the other nice structured OO languages, even C# (Though I believe it is getting to much credit because of name recognition). And AS 2.0 is a nice upgrade.
Anyhow back to your problem.
I figured it would be easier to just make a movie and have you study my approach.
So have a look at the uploaded FLA (I wasn’t sure about what Flash version you are using, so I made it for Flash mx).
I know the mask thingy looks lame, but it’s just an example of how to make more complex transitions.
And forgive the code, in a bit of a hurry ;) no time to be neat and proper like.
(The file is a compressed with rar and not zip.)
itsthejohnes
07-09-2004, 07:18 PM
That is beautiful!!
That helped alot.
The first time I did it, I was placing the AS under the AS code for the movieclip image, which did not work, then I moved the code to the AS "container" for the whole flash document, like you had it in your example, and it worked.
Thanks alot again
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.