ok, I’ve been using flash for a long time, but I’m still kinda new to advanced AS2. I am creating a photo album and I need to make a preloader. Basically what my album does is load about 12 full size photos at once, and displays them all as thumbnails on the side. There is a larger window that displays whichever one you click on in the thumb gallery. and by default on the opening it displays the first pic. I created this project for a friend hoping to learn how to do this completely in actionscript. Which so far I have done successfully. Now, I want to go in where I have the function that loads the pictures into the movie and add a preloader. This way when the page opens up, every photo displays a percentage of the loading picture.
Here is my actionscript:
var filePath:String = "pics/";
var clicks:Number = 0;
var picAmount:Number = 33;
var lastPage = picAmount-11;
function newClip(libName, instName, objWidth, objHeight, xpos, ypos) {
attachMovie(libName, instName, getNextHighestDepth());
this[instName]._width = objWidth;
this[instName]._height = objHeight;
this[instName]._x = xpos;
this[instName]._y = ypos;
}
function fadeIn() {
this.container._alpha = 0;
_root.onEnterFrame = function() {
container._alpha += 6;
if (container._alpha>99) {
container._alpha = 100;
delete _root.onEnterFrame;
}
};
}
function newPic(contName, picNum, xpos, ypos, picWidth, picHeight, type) {
var aNewPic = attachMovie("dummy", contName, this.getNextHighestDepth());
var picNum = picNum;
var fileName = filePath+"Picture"+picNum+".jpg";
var my_mcl = new MovieClipLoader();
var myListener = new Object();
myListener.onLoadInit = function(target_mc) {
target_mc._x = xpos;
target_mc._y = ypos;
target_mc._width = picWidth;
target_mc._height = picHeight;
if (type == 1) {
target_mc.onRelease = function() {
fadeIn();
loadMovie(fileName, "container");
};
} else if (type == 2) {
target_mc.onRollOver = function() {
//trace(this+" onRollOver called");
};
}
};
my_mcl.addListener(myListener);
my_mcl.loadClip(fileName, aNewPic);
}
function prevNext(instName:String, xpos:Number) {
attachMovie("arrowMC", instName, getNextHighestDepth());
this[instName]._x = xpos;
this[instName]._y = 520;
this[instName]._width = 18;
this[instName]._height = 18;
}
function page(startNum) {
var addNum:Number = startNum+12;
var subNum:Number = startNum-12;
newPic("thumb01", startNum, 60, 124, 45, 30, 1);
newPic("thumb02", startNum+1, 111, 124, 45, 30, 1);
newPic("thumb03", startNum+2, 60, 160, 45, 30, 1);
newPic("thumb04", startNum+3, 111, 160, 45, 30, 1);
newPic("thumb05", startNum+4, 60, 196, 45, 30, 1);
newPic("thumb06", startNum+5, 111, 196, 45, 30, 1);
newPic("thumb07", startNum+6, 60, 232, 45, 30, 1);
newPic("thumb08", startNum+7, 111, 232, 45, 30, 1);
newPic("thumb09", startNum+8, 60, 268, 45, 30, 1);
newPic("thumb10", startNum+9, 111, 268, 45, 30, 1);
newPic("thumb11", startNum+10, 60, 304, 45, 30, 1);
newPic("thumb12", startNum+11, 111, 304, 45, 30, 1);
newPic("thumb13", startNum+12, 60, 340, 45, 30, 1);
newPic("thumb14", startNum+13, 111, 340, 45, 30, 1);
newPic("thumb15", startNum+14, 60, 376, 45, 30, 1);
newPic("thumb16", startNum+15, 111, 376, 45, 30, 1);
newPic("thumb17", startNum+16, 60, 412, 45, 30, 1);
newPic("thumb18", startNum+17, 111, 412, 45, 30, 1);
newPic("thumb19", startNum+18, 60, 448, 45, 30, 1);
newPic("thumb20", startNum+19, 111, 448, 45, 30, 1);
newPic("container", startNum, 186, 150, 493, 331, 2);
prevNext("nextButt", 195);
this.nextButt.onRelease = function() {
if (startNum>=lastPage) {
} else {
page(addNum);
}
};
prevNext("prevButt", 100);
this.prevButt.onRelease = function() {
if (startNum<=1) {
} else {
page(subNum);
}
};
this.prevButt._rotation = 180;
}
newClip("redMC", "red", 194, 629, 53, 0);
newClip("picAreaMC", "picArea", 542, 380, 166, 124);
newClip("LogoMC", "logo", 245, 72, 30, 30);
newClip("backButtMC", "back", 130, 59, 77, 533);
this.back.onRelease = function() {
getURL("../index.html");
};
page(1);
I have searched all over the internet for answers to my problem, including preloader tutorials, and nothing covers exactly what I want to do. Please help.