Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help needed with actionscript in dropdownmenu 1

Status
Not open for further replies.

goaganesha

Programmer
Dec 4, 2001
178
BE
Hi, I’m trying to make a dropdownmenu but there seems to be something wrong with my actionscript.
Here is what I’ve done :
On scene1 there is a button with following action in the object panel :
//==========================
on (rollOver)
{
_root.submenu1.gotoAndPlay("over");
}
//==========================
The mc « submenu1 » is also on scene1
It starts with an empty frame labeled « normal » and a stop (); action
The second frame is labeled « over » and is the start of an animation which lets the submenu drop down.
The last frame is labeled « final » and contains another movieclip called « sub1total » and a stop() ; action

« sub1total » has 1 frame with a stop action and contains the different subbuttons + a fake button which covers the button on scene 1 once the menu is open.

In the objectpanel of « sub1total » I have put following code :
//==========================

onClipEvent (enterFrame)
{
bounds = this.getBounds(_root);

if ((_root.xmouse <= bounds.xMax) &&
(_root.xmouse >= bounds.xMin) &&
(_root.ymouse <= bounds.yMax) &&
(_root.ymouse >= bounds.yMin))
{
_root.submenu1.gotoAndStop(&quot;final&quot;);

}

else
{
_root.submenu1.gotoAndStop(&quot;normal&quot;);
}
}
//============================

The problem is that the if statement never seems to be true ‘cause the dropdownmenu shuts right after it was opened. If I delete the else statement the menu stays open but won’t close once the mouse leaves the submenu area. To me it seems that the if statement should be true ‘cause the « submenu1 » mc covers the button which triggers the « on (rollOver) » event on scene1, so the mouse is over the « sub1total » area.
Thanx for your help
 
Have you tried to trace (with the trace action - results in the output window) the value of bounds, write after you defined it, and of the xmouse & ymouse within the if statement?
Seems to me, conditions are not met in the if statement!

Regards,
wink4.gif
ldnewbie
 
Sorry typo...

Have you tried to trace (with the trace action - results in the output window) the value of bounds, right after you've defined it, and of the xmouse & ymouse within the if statement?
Seems to me, conditions are not met in the if statement!

Regards,
wink4.gif
ldnewbie
 
Hello oldnewbie,

thanks for your reply.
I've traced bounds.xMax and it gives a value.(1.11)

When I trace _root.xmouse in the if statement nothing happens. So the condition is not true. I don't understand what is going wrong 'cause when the menu is down, my mouse is always in the menu area.
There also was something else very strange:
When I trace _root.xmouse right before the if statement I get blanco's. (!?)
The outputscreen starts to scroll but no values are displayed.
Hope you know whats going wrong
Regards,goaganesha
 
Well for one thing... It should be _root._xmouse and not _root.xmouse.

I've never seen (or used) this getBounds(); stuff, so don't know if it'll solve your problem... But you should get a trace now before the if statement!

Regards,
wink4.gif
ldnewbie
 
THANX!!!

You solved the problem. It works fine now.
The getBounds(); returns 4 values: xMin, xMax, yMin, yMax.
It works great for positioning sliders on sliderbars etc.
If you want to change the position of the bar for layout reasons, the slider wil always stay on the bar.

regards,
goaganesha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top