# Preloader and image load for sen's xml portfolio

**URL:** https://forum.kirupa.com/t/preloader-and-image-load-for-sens-xml-portfolio/178565
**Category:** Uncategorized
**Created:** [February 11, 2006, 11:57pm UTC](https://forum.kirupa.com/t/preloader-and-image-load-for-sens-xml-portfolio/178565 "2006-02-11T23:57:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dru\_nasty](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@dru\_nasty](https://forum.kirupa.com/u/dru_nasty)
#### Post date: [February 11, 2006, 11:57pm UTC](https://forum.kirupa.com/t/preloader-and-image-load-for-sens-xml-portfolio/178565/1 "2006-02-11T23:57:57Z")

</div>

I’m trying to modify Sen’s xml portfolio a bit but im hung up on two things.

1. How can i add a simple preloader for the big pics that are loaded in?

2. How can I load the first image automatically?

Here’s the code: (I also added a fade prototype for the thumbs. that’s the only change made so far)

```auto

MovieClip.prototype.fader = function(thumb) {
	this.onEnterFrame = function() {
		this._alpha += (thumb-this._alpha)/8;
		if (this._alpha>thumb-5 && this._alpha<thumb+5) {
			delete this.onEnterFrame;
		}
	}
}

var thumb_spacing = 40;

// load variables object to handle loading of text
var description_lv = new LoadVars();
description_lv.onData = function(raw_text){
	description_txt.text = raw_text;
}

function GeneratePortfolio(portfolio_xml){
	var portfolioPictures = portfolio_xml.firstChild.childNodes;
	for (var i = 0; i < portfolioPictures.length; i++){
		var currentPicture = portfolioPictures*;
		
		var currentThumb_mc = menu_mc.createEmptyMovieClip("thumbnail_mc"+i,i);
		currentThumb_mc._x = i * thumb_spacing;
		
		currentThumb_mc.createEmptyMovieClip("thumb_container",0);
		currentThumb_mc.thumb_container.loadMovie(currentPicture.attributes.thumb);
		
		currentThumb_mc.title = currentPicture.attributes.title;
		currentThumb_mc.image = currentPicture.attributes.image;
		currentThumb_mc.description = currentPicture.attributes.description;
		

		currentThumb_mc.onRollOver = currentThumb_mc.onDragOver = function(){
			this.fader(30);
			info_txt.text = this.title;
		}
		currentThumb_mc.onRollOut = currentThumb_mc.onDragOut = function(){
			this.fader(100);
			info_txt.text = "";
		}
		currentThumb_mc.onRelease = function(){
			image_mc.loadMovie(this.image);
			description_lv.load(this.description);
		}
	}
}

// xml object for xml content (defines sources for selections)
var portfolio_xml = new XML();
portfolio_xml.ignoreWhite = true;
portfolio_xml.onLoad = function(success){
	if (success) GeneratePortfolio(this);
	else trace("Error loading XML file"); // no success? trace error (wont be seen on web)
}
// load
portfolio_xml.load("portfolio.xml");

```

p.s. I’ve searched through all the threads on this but alot of the examples where modified beyond what i wanted so the code used was applied to code i’m not even using in this version. Thanks all.
