skyflower
07-10-2005, 07:55 PM
guys,
at least tell me if there's hope.
I'm trying to load jpegs of different sizes and and space them evenly. Here's my code:
total_images = _global.total;
h_pos = 10; // starting horizontal position of grid
v_pos = 10; // starting vertical position of grid
img_clips = new Array(); // movieclips to contain thumbs
img_urls = new Array(); // urls of the jpgs to be loaded as thumbs
for (i=0; i<total_images; i++) {
img_urls.push("images/img" + i + ".jpg"); // populate thumb_graphics with jpg urls
}
function loadImage(num:Number) {
// create container
initObj = {_x: h_pos, _y: v_pos};
curr = this.attachMovie("img_container", "ic" + num + "_mc", num, initObj);
img_clips.push(curr);
// load image
var imgURL = img_urls[num];
img_clips[num].loadMovie(imgURL);
img_clips[num].onEnterFrame = checkIfDone();
}
function checkIfDone() {
var lod = this.getBytesLoaded();
var tot = this.getBytesTotal();
if (lod && tot){
var percent_loaded = lod/tot;
if (percent_loaded == 1){
count++;
if (count < total_images) {
h_pos += this[img_clips[i]]._width;
loadImage(count);
}
delete this.onEnterFrame;
}
}
}
var count=0;
loadImage(count);
where _global.total is the total number of images to load.
so I figured where my problem is. I am creating bunch of empty movie clips and loading jpegs into them. Then, I'm keeping references to these movies in an array. Now, I have onFrameEnter event, that waits until jpeg is loaded, and then updates h_pos (the place to start next movie clip at) and goes to download next jpeg. So, all jpegs get downloaded, so my function works. But, the call to this._width always returns 115, and calls to img_clips[count]._width, or this[img_clips[count]]._width, or eval(img_clips[count])._width all return "undefined".
WHY??????????????????
I've seen people doing it on countless scripts, and mine is the only one not working. What am I doing wrong???
Oh, btw, if I change it so that all movies are created at coordinates (0,0), they are scattered all over the place horizontally.
PLZ HELP
at least tell me if there's hope.
I'm trying to load jpegs of different sizes and and space them evenly. Here's my code:
total_images = _global.total;
h_pos = 10; // starting horizontal position of grid
v_pos = 10; // starting vertical position of grid
img_clips = new Array(); // movieclips to contain thumbs
img_urls = new Array(); // urls of the jpgs to be loaded as thumbs
for (i=0; i<total_images; i++) {
img_urls.push("images/img" + i + ".jpg"); // populate thumb_graphics with jpg urls
}
function loadImage(num:Number) {
// create container
initObj = {_x: h_pos, _y: v_pos};
curr = this.attachMovie("img_container", "ic" + num + "_mc", num, initObj);
img_clips.push(curr);
// load image
var imgURL = img_urls[num];
img_clips[num].loadMovie(imgURL);
img_clips[num].onEnterFrame = checkIfDone();
}
function checkIfDone() {
var lod = this.getBytesLoaded();
var tot = this.getBytesTotal();
if (lod && tot){
var percent_loaded = lod/tot;
if (percent_loaded == 1){
count++;
if (count < total_images) {
h_pos += this[img_clips[i]]._width;
loadImage(count);
}
delete this.onEnterFrame;
}
}
}
var count=0;
loadImage(count);
where _global.total is the total number of images to load.
so I figured where my problem is. I am creating bunch of empty movie clips and loading jpegs into them. Then, I'm keeping references to these movies in an array. Now, I have onFrameEnter event, that waits until jpeg is loaded, and then updates h_pos (the place to start next movie clip at) and goes to download next jpeg. So, all jpegs get downloaded, so my function works. But, the call to this._width always returns 115, and calls to img_clips[count]._width, or this[img_clips[count]]._width, or eval(img_clips[count])._width all return "undefined".
WHY??????????????????
I've seen people doing it on countless scripts, and mine is the only one not working. What am I doing wrong???
Oh, btw, if I change it so that all movies are created at coordinates (0,0), they are scattered all over the place horizontally.
PLZ HELP