Hey all.
I am building an image viewing application in Flash which loads a list of thumbnail images, and generates a button for each. When the user clicks on the thumbnail button, the full size images shows up.
I’m having some difficulty with making the buttons show up. I know they are created because they do show up in the objects list. I’ve included my code below. If you see what I’m doing wrong, or if there’s a better way to do this please tell me. Thanks in advance.
If it helps, I’ve also tried using attachMovie instead of createEmptyMovieClip to no avail.
Here we go.
In my main timeline, on frame 1:
[font=Courier New]var imagesPath = “http://domain/images/”;
// create a global class ThumbButton
_global.ThumbButton = function (thumbUrl, imgUrl){
this.thumbUrl = thumbUrl; // url to thumbnail image
this.imgUrl = imgUrl; // url to actual image
};
ThumbButton.prototype.test = function(){ //testing
trace(“thumbBtn : <” + this.thumbUrl + “> / <” + this.imgUrl);
}
var glamArray = new Array();
var numGlam = 28; // # of pictures
var glamFilename = “glam”;
for (var i = 1; i < numGlam; i++){
var thumb = new ThumbButton(
imagesPath + glamFilename + i + "t.jpg",
imagesPath + glamFilename + i + “.jpg”);
glamArray.push(thumb);
}
[/font]_________________________________________________________
[font=Courier New]
[font=Verdana]In the first frame of the movie clip that I want to load the buttons on I have:[/font]
[/font]__________________________________________________________
[font=Courier New]var xPos = 0;
// loop throught the array of thumbButtons
for (var i=0; i < _root.glamArray.length; i++){
thumb = glamArray*;
// create a empty movie clip to hold the button
tButton = this.createEmptyMovieClip("tButton"+i,i);
// position and resize
tButton._x = xPos;
tButton._y=-90;
tButton._width = 20
tButton._height = 20;
//load the thumbnail image into the movie clip
tButton.loadMovie(thumb.thumbUrl);
tButton._visible = true;
xPos+= 22; // incr the position
// I'm not worried about the actual fetching of the
// image at this point
tButton.onRelease = function(){
trace("fetch " + thumb.imgUrl);
_root.fetchImage(thumb.imgUrl);
};
}
stop();
[/font]__________________________________________________________