Hi guys,
I’m fairly new to flash so i’d really appreciate your help. I would like to add preloaders to the thumbnail data in this script. Anyone know how to do that ?
_root.menuarrow_up._visible = false;
_root.menuarrow_down._visible = false;
var thumbHolder;
import flash.geom.Transform;
import flash.geom.ColorTransform;
GenerateMenu = function(container, name, x, y, depth, node_xml) {
// variable declarations
//trace(node_xml);
var curr_node;
_global.curr_item
curr_item.preloader._visible = false;
var curr_menu = container.createEmptyMovieClip(name, depth);
// for all items or XML nodes (items and menus)
// within this node_xml passed for this menu
for (var i=0; i<node_xml.childNodes.length; i++) {
// movieclip for each menu item
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
//trace("curr_menu" + " " + curr_menu);
curr_item._x = x
//trace(curr_item._x);
//curr_item._y = y*i + curr_item._height;
curr_item._y = curr_item._height+y+curr_item._height*i;
curr_item.trackAsMenu = true;
// item properties assigned from XML
curr_node = node_xml.childNodes*;
//trace('curr_node' + ' ' + curr_node);
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
// item submenu behavior for rollover event
if (node_xml.childNodes*.nodeName == "menu"){
// open a submenu
//trace(node_xml.childNodes*.nodeName);
curr_item.node_xml = curr_node;
//trace(curr_item);
curr_item.onRollOver = curr_item.onDragOver = function(){
var textCol = new Color(this.name);
textCol.setRGB(0x000000);
this.menuitem_hit._alpha = 0;
clickSound = new Sound();
clickSound.attachSound("click2");
clickSound.start(0, 1);
//trace(x);
var x = this._x;
var y = this._y;
//trace(x);
// show a hover color
//trace(this.node_xml);
var col = new Color(this.background);
col.setRGB(0xf4faff);
};
}else{ // nodeName == "item"
// close existing submenu
curr_item.onRollOver = curr_item.onDragOver = function(){
var textCol = new Color(this.name);
textCol.setRGB(0x000000);
this.menuitem_hit._alpha = 0;
var col = new Color(this.background);
col.setRGB(0xf4faff);
};
}
curr_item.onRollOut = curr_item.onDragOut = function(){
var textCol = new Color(this.name);
textCol.setRGB(0x666666);
this.menuitem_hit._alpha = 75;
clickSound = new Sound();
stopAllSounds;
// restore color
var col = new Color(this.background);
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
};
// any item, menu opening or not can have actions
curr_item.onRelease = function(){
Actions[this.action](this.variables);
//trace(this.action);
CloseSubmenus();
};
} // end for loop
};
// create the main menu, this will be constantly visible
CreateMainMenu = function (x, y, depth, menu_xml) {
// generate a menu list
GenerateMenu(this, “mainmenu_mc”, x, y, depth, menu_xml.firstChild);
//trace(menu_xml.firstChild);
// close only submenus if visible durring a mouseup
// this main menu (mainmenu_mc) will remain
};
Actions = Object();
Actions.loadSection = function(loadVar) {
loadMovieNum(loadVar, 1);
//trace(“urlVar” + urlVar);
};
Actions.message = function(msg) {
message_txt.text = msg;
};
Actions.newMenu = function(menuxml) {
menu_xml.load(menuxml);
};
// load XML, when done, run CreateMainMenu to interpret it
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok) {
// create main menu after successful loading of XML
_global.thumbHolder;
if (ok) {
CreateMainMenu(90, -30, 0, this);
//script used to create the thumbnails
numimages = this.firstChild.childNodes.length;
spacing = 150;
for (i=0; i<numimages; i++) {
this.picHolder = this.firstChild.childNodes*;
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._y = i*spacing;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder._alpha = 100;
}
} else {
message_txt.text = "error: XML not successfully loaded";
}
};
// load first XML menu
menu_xml.load(“menu2.xml”);
var borderHeight:Number = 600;
var topOfMenu:Number = 0;
var mItemHeight:Number = -150;
var menuHeight:Number = menu_xml.firstChild.childNodes.length;
_root.menuUp_btn.onRollOver = function() {
clickSound = new Sound();
clickSound.attachSound(“click2”);
clickSound.start(0, 99);
this.onEnterFrame = function() {
if (_root.xmlContent._y != topOfMenu) {
_root.xmlContent._y += 25;
_root.menuarrow_up._visible = true;
}else{
stopAllSounds();
_root.menuarrow_up._visible = false;
}
};
};
_root.menuUp_btn.onRollOut = function() {
_root.menuarrow_up._visible = false;
this.onEnterFrame = null;
stopAllSounds();
};
_root.menuDown_btn.onRollOver = function() {
clickSound = new Sound();
clickSound.attachSound("click2");
clickSound.start(0, 99);
this.onEnterFrame = function() {
if (_root.xmlContent._y != menu_xml.firstChild.childNodes.length*mItemHeight+borderHeight) {
_root.xmlContent._y -= 25;
_root.menuarrow_down._visible = true;
}else{
stopAllSounds();
_root.menuarrow_down._visible = false;
}
};
};
_root.menuDown_btn.onRollOut = function() {
_root.menuarrow_down._visible = false;
this.onEnterFrame = null;
stopAllSounds();
};