aliasworkshop
06-06-2005, 05:35 PM
I'm trying to figure out this script for a project at work, but I'm at a loss what to do next.
We're trying to make a "media bank" that displays thumbnails of images from a directory in a grid on the stage. This would be easy for me if it weren't for the fact that they want me to make proportional thumbnails on the fly from full images (of varying sizes) and a rollover effect. The only information I'm getting from the database is a .txt file called "flash.txt" with a string of variables for the image names, which looks like this:
&totalfiles=32&path1=im/image1.jpg...
I have 16 movieclips on the stage (s1) for 16 images, each with an empty movieclip inside (c1) - this is where the images are loaded into. The s1 movieclip masks each internal c1 movieclip so that only a portion is shown of the image.
The first frame of the whole movie has the following code on it:
paths = new Array();
initial = 0;
num_mc = 16;
files = new Array();
vars = new LoadVars();
vars.onLoad = function() {
num = this.totalfiles;
counter = num-1;
for (i in this) {
if (i != "onLoad" && i != "totalfiles") {
files[counter] = this[i];
counter--;
}
}
loadImages(initial);
};
vars.load("flash.txt");
function loadImages(resetnext) {
s1.c1.loadMovie(files[resetnext++]);
paths[0] = files[resetnext-1];
s2.c2.loadMovie(files[resetnext++]);
paths[1] = files[resetnext-1];
s3.c3.loadMovie(files[resetnext++]);
paths[2] = files[resetnext-1];
s4.c4.loadMovie(files[resetnext++]);
paths[3] = files[resetnext-1];
s5.c5.loadMovie(files[resetnext++]);
paths[4] = files[resetnext-1];
s6.c6.loadMovie(files[resetnext++]);
paths[5] = files[resetnext-1];
s7.c7.loadMovie(files[resetnext++]);
paths[6] = files[resetnext-1];
s8.c8.loadMovie(files[resetnext++]);
paths[7] = files[resetnext-1];
s9.c9.loadMovie(files[resetnext++]);
paths[8] = files[resetnext-1];
s10.c10.loadMovie(files[resetnext++]);
paths[9] = files[resetnext-1];
s11.c11.loadMovie(files[resetnext++]);
paths[10] = files[resetnext-1];
s12.c12.loadMovie(files[resetnext++]);
paths[11] = files[resetnext-1];
s13.c13.loadMovie(files[resetnext++]);
paths[12] = files[resetnext-1];
s14.c14.loadMovie(files[resetnext++]);
paths[13] = files[resetnext-1];
s15.c15.loadMovie(files[resetnext++]);
paths[14] = files[resetnext-1];
s16.c16.loadMovie(files[resetnext++]);
paths[15] = files[resetnext-1];
}
stop();
There are two buttons on the stage ( < and > ) that load the next set of 16 images. The buttons call the function above using the following script:
//For the forward button
on (release) {
initial+=num_mc;
loadImages(initial);
}
// For the back button
on (release) {
initial-=num_mc;
loadImages(initial);
}
Now, all of this works fine, but how to resize these images proportionally to the clip is what's getting me. I originally tried an onClipEvent(data) for the following code, then an onClipEvent(load), and I also tried putting all the resize code in a function and executing that when the < or > buttons are pressed, but it doesn't work. The following code keeps the functionality of "resetnext" working, but the image continuously blinks because of the onEnterFrame:
//This is on the first frame inside the s1 clip.
this.onEnterFrame = function() {
if (c1.getBytesTotal()>4 && c1.getBytesLoaded()>=c1.getBytesTotal()) {
dw = (142/c1._width)*100;
dh = (108/c1._height)*100;
if (dw<dh) {
c1._xscale = dh;
c1._yscale = dh;
} else {
c1._xscale = dw;
c1._yscale = dw;
}
delete c1.onEnterFrame;
}
};
No matter where I put the "delete. c1.onEnterFrame" the c1 clip continues to blink. And also, if I want the < and > buttons to reset the whole set of images, wouldn't I need onEnterFrame still firing to detect when the new image is loaded into c1 and resize it??
My source file is here: http://galatea.stetson.edu/~dquinone/transfer/bank2.zip
The external files are in the zip.
Ignore the code on the other movieclips in this file, because what I'm implementing here is only on the first s1 clip on the stage (hide everything and unhide the MC layer on the very bottom to get to these clips).
If anyone can help, I'd very much appreciate it!
Thanks in advance,
aliasworkshop
We're trying to make a "media bank" that displays thumbnails of images from a directory in a grid on the stage. This would be easy for me if it weren't for the fact that they want me to make proportional thumbnails on the fly from full images (of varying sizes) and a rollover effect. The only information I'm getting from the database is a .txt file called "flash.txt" with a string of variables for the image names, which looks like this:
&totalfiles=32&path1=im/image1.jpg...
I have 16 movieclips on the stage (s1) for 16 images, each with an empty movieclip inside (c1) - this is where the images are loaded into. The s1 movieclip masks each internal c1 movieclip so that only a portion is shown of the image.
The first frame of the whole movie has the following code on it:
paths = new Array();
initial = 0;
num_mc = 16;
files = new Array();
vars = new LoadVars();
vars.onLoad = function() {
num = this.totalfiles;
counter = num-1;
for (i in this) {
if (i != "onLoad" && i != "totalfiles") {
files[counter] = this[i];
counter--;
}
}
loadImages(initial);
};
vars.load("flash.txt");
function loadImages(resetnext) {
s1.c1.loadMovie(files[resetnext++]);
paths[0] = files[resetnext-1];
s2.c2.loadMovie(files[resetnext++]);
paths[1] = files[resetnext-1];
s3.c3.loadMovie(files[resetnext++]);
paths[2] = files[resetnext-1];
s4.c4.loadMovie(files[resetnext++]);
paths[3] = files[resetnext-1];
s5.c5.loadMovie(files[resetnext++]);
paths[4] = files[resetnext-1];
s6.c6.loadMovie(files[resetnext++]);
paths[5] = files[resetnext-1];
s7.c7.loadMovie(files[resetnext++]);
paths[6] = files[resetnext-1];
s8.c8.loadMovie(files[resetnext++]);
paths[7] = files[resetnext-1];
s9.c9.loadMovie(files[resetnext++]);
paths[8] = files[resetnext-1];
s10.c10.loadMovie(files[resetnext++]);
paths[9] = files[resetnext-1];
s11.c11.loadMovie(files[resetnext++]);
paths[10] = files[resetnext-1];
s12.c12.loadMovie(files[resetnext++]);
paths[11] = files[resetnext-1];
s13.c13.loadMovie(files[resetnext++]);
paths[12] = files[resetnext-1];
s14.c14.loadMovie(files[resetnext++]);
paths[13] = files[resetnext-1];
s15.c15.loadMovie(files[resetnext++]);
paths[14] = files[resetnext-1];
s16.c16.loadMovie(files[resetnext++]);
paths[15] = files[resetnext-1];
}
stop();
There are two buttons on the stage ( < and > ) that load the next set of 16 images. The buttons call the function above using the following script:
//For the forward button
on (release) {
initial+=num_mc;
loadImages(initial);
}
// For the back button
on (release) {
initial-=num_mc;
loadImages(initial);
}
Now, all of this works fine, but how to resize these images proportionally to the clip is what's getting me. I originally tried an onClipEvent(data) for the following code, then an onClipEvent(load), and I also tried putting all the resize code in a function and executing that when the < or > buttons are pressed, but it doesn't work. The following code keeps the functionality of "resetnext" working, but the image continuously blinks because of the onEnterFrame:
//This is on the first frame inside the s1 clip.
this.onEnterFrame = function() {
if (c1.getBytesTotal()>4 && c1.getBytesLoaded()>=c1.getBytesTotal()) {
dw = (142/c1._width)*100;
dh = (108/c1._height)*100;
if (dw<dh) {
c1._xscale = dh;
c1._yscale = dh;
} else {
c1._xscale = dw;
c1._yscale = dw;
}
delete c1.onEnterFrame;
}
};
No matter where I put the "delete. c1.onEnterFrame" the c1 clip continues to blink. And also, if I want the < and > buttons to reset the whole set of images, wouldn't I need onEnterFrame still firing to detect when the new image is loaded into c1 and resize it??
My source file is here: http://galatea.stetson.edu/~dquinone/transfer/bank2.zip
The external files are in the zip.
Ignore the code on the other movieclips in this file, because what I'm implementing here is only on the first s1 clip on the stage (hide everything and unhide the MC layer on the very bottom to get to these clips).
If anyone can help, I'd very much appreciate it!
Thanks in advance,
aliasworkshop