View Full Version : size of loaded picture
rewko
July 19th, 2003, 01:39 PM
Hallo everybody,
I need to establish size of picture (*.jpg) loaded in swf file. I used this script for load the picture:
_root.createEmptyMovieClip(picture, 9876);
loadMovie(obrazok.jpg, 9876);
trace(picture._width);
but traced number is always 0 however the real size of picture is 256 x 192. How should I change the script for it works?
λ
July 19th, 2003, 01:48 PM
_root.createEmptyMovieClip("picture", 9876);
picture.loadMovie("obrazok.jpg");
_root.onEnterFrame = function(){
if(picture.getBytesLoaded == picture.getBytesTotal && picture.getBytesTotal > 0){
trace(picture._width);
}
}
rewko
July 20th, 2003, 06:33 AM
I dont know why but it doesnt work. Output window isnt even opened...
kode
July 20th, 2003, 06:57 AM
if (picture.getBytesLoaded() == picture.getBytesTotal() && picture.getBytesTotal()>0) {
rewko
July 20th, 2003, 07:13 AM
it makes no change. picture is shown nice but nothing else.
kode
July 20th, 2003, 07:31 AM
The code works fine. What do you want to do exactly?
rewko
July 20th, 2003, 07:45 AM
exactly? i want to align about 15 different sized pictured loaded with code:
for (i=0; i<87; i++) {
_root.group.createEmptyMovieClip(i, i);
loadMovie(picArray[i], i);
setProperty(i, _x, 125*i);
setProperty(i, _y, 0);
}
pictures are good aligned by width because their width is the same. But aligment by height is wrong because it on the top of pic and i want align them on the middle. how can do I this?
kode
July 20th, 2003, 05:27 PM
You could try something like this, I'm not sure if this would be the best way though.
clips = [];
for (i=0; i<87; i++) {
clips[i] = group.createEmptyMovieClip("pic"+i, i);
clips[i].loadMovie(picArray[i]);
clips[i]._x = 125*i;
}
group.createEmptyMovieClip("preloader", 9876);
// change this value to whatever you need
group.preloader.ycenter = 100;
group.preloader.onEnterFrame = function() {
if (clips.length) {
for (i=0; i<clips.length; i++) {
if (clips[i]._width) {
clips[i]._y = this.ycenter-clips[i]._height/2;
clips.splice(i, 1);
}
}
} else {
this.removeMovieClip();
}
};
:-\
rewko
July 22nd, 2003, 02:08 PM
It works, It really works!!!
Thank you very much for your help. ;)
kode
July 22nd, 2003, 05:00 PM
You're welcome. =)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.