PDA

View Full Version : How to make the rollover? XML menu?



icep
1st December 2005, 21:09
Hi!

I was trying to make my menu and come this far www.icep-design.com/hej but run into problems. So i started all over and made it load from XML but i haven't yet figure out a way to make my submenu. If u take a look at www.icep-design.com/hej and rollover the laserdome button you can see what im going after. I still have no idea how to make it. anybody that can help me?

I post my AS here:

stop ();
import mx.transitions.Tween;
import mx.transitions.easing. *;
//Making submeny invisible
_root.over_mc._visible = false;
//xml test
menuXml = new XML;
menuXml.ignoreWhite = true;
menuXml.load ("menu_new.xml")
menuXml.onLoad = function (success)
{
if (success)
{
menuItem = this.firstChild.childNodes;
for (var i = 0; i < menuItem.length; i ++)
{
item = _root ["button_mc_" + i];
item.upper_text.text = menuItem [i].attributes.name;
item.lower_text.text = menuItem [i].attributes.lower;
//text colors
item.upper_text.textColor = 0x969696;
item.lower_text.textColor = 0xBBBBBB;
//function for submenus
if (menuItem [i].nodeName == "menu")
{
// open a submenu
curr_item.node_xml = curr_node;
item.onRollOver = function ()
{
trace ("hej")
}
}
//rollOver colors
item.onRollOver = function ()
{
//Colors of the text
this.upper_text.textColor = 0x000000;
this.lower_text.textColor = 0x000000;
}
//rollOut colors
item.onRollOut = function ()
{
this.upper_text.textColor = 0x969696;
this.lower_text.textColor = 0xBBBBBB;
}
//trace (this + " >> " + i + " : " + menuItem.length);
}
}
}
//rollOut remove movieclip on submenu
_root.over_mc.onRollOut = function ()
{
_root.over_mc._visible = false;
}


And here is my XML:

http://www.icep-design.com/menu_new.xml

supern0va
2nd December 2005, 00:52
:D

You're better of store the attributes into a 2-dimensional array:
Ie

var _array:Array = [master Menu,[submenus]]

then assign each menu mc with the second array prop

example thisMC.subMenu = _array[k][1];
This will pass through: _array[k][1] = [submenus].props

Hope this makes sense. :dance:

icep
2nd December 2005, 08:42
no i didn't really make sense... but will try to figure it out. Or can you mayeb try to explain it for me?

supern0va
2nd December 2005, 10:42
Ok...

The nodes are actually MC that you can click (is this right ?)

so

use an array to store the values from your xml

Modified Snippet Below:


var cleanArray:Array = []; //this will store the values in 2-dimensions
menuXml = new XML;
menuXml.ignoreWhite = true;
menuXml.load ("menu_new.xml")
menuXml.onLoad = function (success){
if (success){
menuItem = this.firstChild.childNodes;
for (var i = 0; i < menuItem.length; i ++){
item = _root ["button_mc_" + i];
cleanArray.push[
[menuItem [i].attributes.name],
[menuItem [i].attributes.lower]
];
}
}

Now you can assign the values to whatever mc you will click to create the sub-menu

ie clickMenu.subMenu = cleanArray[k][0];

icep
2nd December 2005, 16:44
Ok thx! But how a little problem don't know how to create the submenu MC don't really know how to make it go with the tween and how to make it stay so user can click on it. As you can see on www.icep-design.com/hej that was my problem from the beginning...

supern0va
3rd December 2005, 00:49
If you zip the fla up and host it somewhere.
I can have a look @ it for you.

Its pretty straight forward the Mc bits

icep
4th December 2005, 16:00
If you zip the fla up and host it somewhere.
I can have a look @ it for you.

Its pretty straight forward the Mc bits

Ok thx here is the link to the zip file www.icep-design.com/menyn.zip