Hi all,
I want to create menu and submenu in flash. First I tried using Menu component. But I can't find its width programmatically. So, I used Movie clip. Here, Iused to load the values from XML. Whenever any menuitems are changed in XMl, The modified value is displayed in movie clip, but its width won't be changed. How to increase the width programmatically.
Or other than this, how to create menu and sub menu? It will be displayed in the bottom of the screen. and it will displayed from bottom to top.
help me to solve this prob.
Thanks in advance
<code>
GenerateMenu = function(container, name,x, y, depth, node_xml)
{
var curr_node;
var curr_item;
var temp:Number;
var curr_menu = container.createEmptyMovieClip(name, depth);
for (var i=node_xml.childNodes.length-1; i>=0; i--)
{
var menuname = node_xml.childNodes[i].attributes.name;
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
if (menuname.length > 8)
{
curr_item._x = x ;
curr_item._y = y + i*curr_item._height;
curr_item.trackAsMenu = true;
curr_item._width = 150;
var col = new Color(this.background);
col.setRGB(0x99ff99);
curr_node = node_xml.childNodes[i];
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
}
if (node_xml.childNodes[i].nodeName == "menu")
{
curr_item.node_xml = curr_node;
curr_item.onRollOver = curr_item.ondragOver = function()
{
temp = node_xml.childNodes.length;
var x = curr_item._x - 95;
var y = (curr_item._y + i*curr_item._height);
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000, this.node_xml);
var col = new Color(this.background);
col.setRGB(0x00ff00);
};
}
else
{
curr_item.arrow._visible = false;
curr_item.onRollOver = curr_item.ondragOver = function()
{
curr_menu.submenu_mc.removeMovieClip();
var col = new Color(this.background);
col.setRGB(0x00ff00); //0xf4faff
};
}
curr_item.onRollOut = curr_item.ondragOut = function()
{
var col = new Color(this.background);
col.setRGB(0x3333ff); //0xf4faff
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
curr_item.onRelease = function()
{
Actions[this.action](this.variables);
CloseSubmenus();
};
} // end for loop
};
CreateMainMenu = function(x, y, depth, menu_xml)
{
GenerateMenu(this, "mainmenu_mc", x, y, 100, menu_xml.firstChild);
mainmenu_mc.onmouseup = function()
{
if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse,true))
{
CloseSubmenus();
}
};
};
CloseSubmenus = function()
{
mainmenu_mc.submenu_mc.removeMovieClip();
};
Actions = Object();
Actions.newMenu = function(menuxml)
{
menu_xml.load(menuxml);
};
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onload = function(ok)
{
if (ok)
{
CreateMainMenu(225, 165, 0, this);
//trace("message area");
}
else
{
trace("error: XML not successfully loaded");
}
};
menu_xml.load("menu.xml");
</code>
Movie clip prob
Page 1 of 15 Replies - 1106 Views - Last Post: 26 August 2007 - 12:41 AM
Replies To: Movie clip prob
#2
Re: Movie clip prob
Posted 16 August 2007 - 10:41 PM
That's a lot to read write now; I'll look over it in the morning.
#3
Re: Movie clip prob
Posted 17 August 2007 - 12:02 AM
#4
Re: Movie clip prob
Posted 17 August 2007 - 10:40 AM
"curr_item._width" should work; is it not?
#5
Re: Movie clip prob
Posted 20 August 2007 - 11:32 PM
FlashNewUser, on 17 Aug, 2007 - 12:02 AM, said:
Yes. That is working. My prob is : I'm passing the parameter to display the menu, Is it possible to display the menu programmatically, i.e I want to calculate the height and width of the menu items.
<code>
curr_item._x = Stage.height - curr_item._width ;
curr_item._y = y + i*curr_item._height;
curr_item.trackAsMenu = true;
if ((curr_item._y >= Stage.height) and (curr_item._x <= Stage.width))
{
curr_item._y = Stage.width - i*curr_item._height;
curr_item._x = Stage.height - curr_item._width ;
}
Like this. Is it correct? or how can i do this?
</code>
Then is it possible to ? how to assign the width and height to stage dynamically? Give me ur suggestion
#6
Re: Movie clip prob
Posted 26 August 2007 - 12:41 AM
You've stated that you want to calculate the width and height dynamically, which is certainly possible, but you've not stated the source of your calculation. Without knowing what you want that size to be based on, there's no way to know if your code is correct.
As for setting the Stage size dynamically, I don't think it's possible. I imagine Adobe would find that to be a security risk.
As for setting the Stage size dynamically, I don't think it's possible. I imagine Adobe would find that to be a security risk.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|