emblewembl
Programmer
I've got a flash movie with some dynamically loaded movieclips which hold a thumbnail of an image. All images from a specified folder are loaded. When each thumbnail is clicked on I want the main large image to change and show the thumbnail in full size. I've tried to add an onPress event to each movieclip but they all end up linking to the last thumbnail loaded - i'm very new to actionscript (I normally develop in C#) so be gentle with me! Any help greatly appreciated
Here's the full code:
i love chocolate

Code:
var x = new XML();
var path = "\\images\\";
//thumbs
var xPos = 466;
var yPos = 103;
var tWidth = 44;
var tHeight = 44;
var tSpace = 5;
var numPhotos = 0;
//main
var xMain = 96;
var yMain = 20;
var mWidth = 268;
var mHeight = 400;
x.ignoreWhite = true;
x.onLoad = function(success) {
if (success) {
x=0;
//main
var mcMain = _root.createEmptyMovieClip( 'main'+i, i+10 );
mcMain._x = i*110;
var imgMain = mcMain.createEmptyMovieClip( 'mImg', 1 );
imgMain._visible = false;
imgMain.loadMovie(path + this.childNodes[0].childNodes[0]);
mcMain.onEnterFrame = function(){
var t = imgMain.getBytesTotal();
var l = imgMain.getBytesLoaded();
if( l == t && t >100 ){
this.onEnterFrame = null;
this._width = mWidth;
this._height = mHeight;
this._x = xMain;
this._y = yMain;
imgMain._visible = true;
}
}
//thumbs
for( i in this.childNodes ){
var mc = _root.createEmptyMovieClip( 'pic'+i, i+10 );
mc._x = i*110;
var img = mc.createEmptyMovieClip( 'img', 1 );
img._visible = false;
var imgPath = path + this.childNodes[i].childNodes[0];
trace("Path 1: " + imgPath);
img.loadMovie(imgPath);
mc.onEnterFrame = function(){
var t = img.getBytesTotal();
var l = img.getBytesLoaded();
if( l == t && t >100 ){
this.onEnterFrame = null;
this._width = tWidth;
this._height = tHeight;
this._x = xPos;
this._y = yPos;
this.onPress = function(){
imgMain.loadMovie(imgPath);
trace("Path 2: " + imgPath);
}
xPos = xPos + tWidth + tSpace;
numPhotos = numPhotos + 1;
if (numPhotos > 3)
{
//build next row of thumbnails
xPos = 466;
yPos = yPos + tHeight + tSpace;
numPhotos = 0;
}
img._visible = true;
outlinePortrait._visible = false;
}
}
}
} else {
trace( 'failed to load xml' );
}
}
x.load('images.xml');
i love chocolate