Hi there, I'm really new to actionscript, but I've managed to put together a flash xml menu. What I know want to do is delay the loading of each item so that the menu loads in a nice 1 at a time fashion. Can anyone help me with this? I'm pretty desperate!
This is the menu as it is:
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
GenerateMenu = function(container, name, x, y, depth, node_xml) {
var curr_node;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name, depth);
for (var i=0; i<node_xml.childNodes.length; i++) {
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
curr_item._y = y + i*curr_item._height;
curr_item._x = x;
curr_item.trackAsMenu = true;
with (curr_item) {
_alpha = 0;
Increment(2000, 20);
}
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(){
var x = this._x + this._width + 3;
var y = this._y + 0;
GenerateMenu(curr_menu, "submenu_mc", x, y, 1000000, this.node_xml);
var col = new Color(this.background);
col.setRGB(000000);
};
}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(000000);
};
}
curr_item.onRollOut = curr_item.onDragOut = function(){
var col = new Color(this.background);
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
curr_item.onRelease = function(){
Actions[this.action](this.variables);
CloseSubmenus();
};
}
};
CreateMainMenu = function(x, y, depth, menu_xml){
GenerateMenu(this, "mainmenu_mc", x, y, depth, 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.loadMov = function(loadVar){
loadMovie(loadVar, "Loader");
menu_xml.load("menu3.xml");
};
Actions.unloadMov = function(urlVar){
unloadMovie("Loader");
};
Actions.message = function(msg){
message_txt.text = msg;
};
Actions.newMenu = function(menuxml){
menu_xml.load(menuxml);
};
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok){
if (ok){
CreateMainMenu(10, 10, 1, this);
}else{
}
};
menu_xml.load("menu1.xml");
Am I right in thinking I need to create a setinterval function perhaps where the loop begins? If so how would I implement.
Any thoughts and solutions on this problem will be greatly appreciated!
Many thanks