# XML Thumbnail preloader?

**URL:** https://forum.kirupa.com/t/xml-thumbnail-preloader/220281
**Category:** flash
**Created:** [March 24, 2007, 6:19pm UTC](https://forum.kirupa.com/t/xml-thumbnail-preloader/220281 "2007-03-24T18:19:32Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![janw](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@janw](https://forum.kirupa.com/u/janw)
#### Post date: [March 24, 2007, 6:19pm UTC](https://forum.kirupa.com/t/xml-thumbnail-preloader/220281/1 "2007-03-24T18:19:32Z")

</div>

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&lt;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&lt;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();  
};
