Uli
February 12, 2004, 5:24pm
1
Hello,
sorry if this has been already asked and replied, i couldn’t find the answers i’m looking for…
I’m loading a pic using a config file like:
[AS]
onClipEvent (load) {
loadText = new LoadVars();
loadText.load(“config.txt”);
loadText.onLoad = function() {
if (this.imageurl != 0) {
_root.createEmptyMovieClip(“img”, 10);
loadMovie(this.imageurl, _root.img);
//trace(_root.img._width)
}
};
}
[/AS]
Now i’d like to check the width and height of the loaded pic by checking the height and width of the holder MC but it always returns 0… Can someone help?
TiA
system
February 12, 2004, 5:50pm
2
Retrieve the width of the movie clip after it is fully loaded:
loadText = new LoadVars();
loadText.load("config.txt");
loadText.onLoad = function() {
if (this.imageurl != 0) {
_root.createEmptyMovieClip("img", 10);
_root.createEmptyMovieClip("loader", 11);
loadMovie(this.imageurl, _root.img);
_root.loader.onEnterFrame = function() {
if (_root.img.getBytesLoaded() == _root.img.getBytesTotal()) {
trace(_root.img._width);
_root.loader.removeMovieClip();
}
};
}
};
system
February 12, 2004, 6:10pm
3
It’s not working…
[AS]
onClipEvent (load) {
loadText = new LoadVars();
loadText.load(“config.txt”);
loadText.onLoad = function() {
if (this.imageurl != 0) {
_root.createEmptyMovieClip(“img”, 10);
_root.createEmptyMovieClip(“loader”, 11);
loadMovie(this.imageurl, _root.img);
_root.loader.onEnterFrame = function() {
if (_root.img.getBytesLoaded() == _root.img.getBytesTotal()) {
trace(_root.img._width);
_root.loader.removeMovieClip();
}
};
}
};
}
[/AS]
something wrong???
Thanks for your time
system
February 12, 2004, 6:27pm
4
Ops, replace this line:
if (_root.img.getBytesTotal() && _root.img.getBytesLoaded() == _root.img.getBytesTotal()) {
system
February 12, 2004, 6:38pm
5
w00t it works, thanks a bunch :} :}
system
February 12, 2004, 6:46pm
7
One question tho, can you explain that line to me??
[AS]
if (_root.img.getBytesTotal() && _root.img.getBytesLoaded() == _root.img.getBytesTotal()) {
[/AS]
cause i don’t understand why if (_root.img.getBytesLoaded() == _root.img.getBytesTotal()){ isn’t enough …
system
February 12, 2004, 6:52pm
8
Because when you create the empty movieclip, it has 0kb.
So for a brief instant, _root.img.getBytesLoaded() == _root.img.getBytesTotal() will be true (they will be both equal to zero) before you load the movie.
To avoid that, we check if _root.img.getBytesTotal() is not equal to zero.
system
February 12, 2004, 6:54pm
9
got it, thanks again for your help, very much apreciated