Hi,
i'm trying to do an image gallery. i was not able to display the thumbnails stored in the array. instead it keep showing the same thumbnails. anyone can help? very much appreciated..
// Arrays that store the filenames of the text, images and thumbnails
var thumbnails:Array = [
"images/image1_thumb.jpg",
"images/image2_thumb.jpg",
"images/image3_thumb.jpg",
"images/image4_thumb.jpg",
"images/image5_thumb.jpg",
"images/image6_thumb.jpg",
"images/image7_thumb.jpg"
];
var images:Array = [
"images/image1.jpg",
"images/image2.jpg",
"images/image3.jpg",
"images/image4.jpg",
"images/image5.jpg",
"images/image6.jpg",
"images/image7.jpg"
];
var textFiles:Array = [
"text/picture1.txt",
"text/picture2.txt",
"text/picture3.txt",
"text/picture4.txt",
"text/picture5.txt",
"text/picture6.txt",
"text/picture7.txt"
];
// NOTE: thumbnail images are 60 x 43 pixels in size
// loop through the array and create the thumbnails and position them vertically
for (var i:int = 0; i <7; i++) {
// create an instance of MyUIThumbnail
var thumbs:MyUIThumbnail = new MyUIThumbnail();
// position the thumbnails on the left vertically
thumbs.y = 43 * i;/*** FILL IN THE BLANK HERE ***/
// store the corresponding full size image name in the thumbnail
// use the "images" array
thumbs.image = "images/image1.jpg";
thumbs.image = "images/image2.jpg";
thumbs.image = "images/image3.jpg";
thumbs.image = "images/image4.jpg";
thumbs.image = "images/image5.jpg";
thumbs.image = "images/image6.jpg";
thumbs.image = "images/image7.jpg";
// store the corresponding text file name in the thumbnail
// use the "textFiles" array
thumbs.textFile = "text/picture1.txt";
thumbs.textFile = "text/picture2.txt";
thumbs.textFile = "text/picture3.txt";
thumbs.textFile = "text/picture4.txt";
thumbs.textFile = "text/picture5.txt";
thumbs.textFile = "text/picture6.txt";
thumbs.textFile = "text/picture7.txt";
thumbs.imageFullSize = full_image_mc ;
// store the reference to the textfield in the thumbnail
thumbs.infoText = info;
// load and display the thumbnails
// use the "thumbnails" array
thumbs.loadThumbnail("images/image1_thumb.jpg");
thumbs.loadThumbnail("images/image2_thumb.jpg");
thumbs.loadThumbnail("images/image3_thumb.jpg");
thumbs.loadThumbnail("images/image4_thumb.jpg");
thumbs.loadThumbnail("images/image5_thumb.jpg");
thumbs.loadThumbnail("images/image6_thumb.jpg");
thumbs.loadThumbnail("images/image7_thumb.jpg");
addChild(thumbs);
}
below is my thumbanail. as
package{
import fl.containers.;
import flash.events.;
import flash.text.;
import flash.net.;
import flash.display.*;
public class MyUIThumbnail extends MovieClip
{
public var image:String = "";
public var textFile:String = "";
var loader:UILoader = new UILoader();
public var imageFullSize:MyFullSizeImage; // reference to loader to show the full size image
public var infoText:TextField; // reference to textfield that displays image infoText
var txtLoader:URLLoader = new URLLoader(); // loader to load the text file
public function MyUIThumbnail()
{
buttonMode = true;
addChild(loader);
this.addEventListener(MouseEvent.CLICK, myClick);
txtLoader.addEventListener(Event.COMPLETE, displayText);
loader.addEventListener(Event.COMPLETE, thumbnailLoaded);
}
public function loadThumbnail(filename:String):void
{
loader.source = filename;
preloader.trackLoading(loader);
}
function myClick(e:MouseEvent):void
{
// load and display the full size image
imageFullSize.loadImage("my_full_mc");
// load and display the text
textLoad("info");
}
function textLoad(file:String) {
// load the text description from the text file
loader.load(new URLRequest(textFile));
}
function displayText(e:Event) {
//display the text when loading is completed
addChild(infoText);
}
function thumbnailLoaded(e:Event) {
loader.width = 60;
loader.height = 43;
}
}
}