Hello all,
I am creating a photo gallery but i have to resize my loaded images into a certain size after loading them into an empty movie clip on stage.
I am resizing my images now through multiplying the _xscale and _yscale of the empty movie clip after loading the image by a certain coefficient, but this implies that i have to know the loaded image size before knowing the right coefficient to use.
Is their anyway to get the _width and _height of the loaded image or the empty movie clip after loading the image into it, since i am getting a 0 for _height and _width for empty movie clip before and after loading the image.
Thanks
system
March 28, 2003, 1:59pm
3
// this is the code used for the image gallery tutorial on kirupa
// see the photo._xscale and photo._yscale code lines
this.pathToPics = “…/All Mine/Photos/”;
this.pArray = new Array(32);
for (kkk = 0; kkk <= 31; kkk++) {
if (kkk < 10) {
this.pArray[kkk] = “DSCF000” + kkk + “.JPG”;
} else {
this.pArray[kkk] = “DSCF00” + kkk + “.JPG”;
}
}
this.fadeSpeed = 20;
this.pIndex = 0;
photo._xscale = photo._xscale0.234375;
photo._yscale = photo._yscale 0.208333;
photo._x = 0;
photo._y = 0;
MovieClip.prototype.changePhoto = function(d) {
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.photo;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
// Actions -----------------------------------------
// these aren’t necessary, just an example implementation
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
}
};
Key.addListener(this);
system
March 28, 2003, 2:08pm
4
try this:
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
**trace(this.photo._width);
trace(this.photo._height);**
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
}
=)
[size=1]ps. please use actionscript formatting tags [ as ] and [ /as ][/size]
system
March 28, 2003, 2:30pm
5
Thanks for your help
But the returned value is still 0 before and after loading the image into the movie clip for the _height and _width
system
March 28, 2003, 2:33pm
6
!? :stunned:
ok… i’ll download the files from the tutorial
system
March 28, 2003, 2:43pm
7
ok. i tested it… and it worked =)
could you attach your files?
system
March 28, 2003, 3:51pm
8
*Originally posted by adham_a *
**Thanks for your help
But the returned value is still 0 before and after loading the image into the movie clip for the _height and _width **
Before, yes, after, no. Kax’s code works perfectly