-
createemptymovieclip height width
I'm trying to trace the height/width of a loaded jpg file:
Code:
this.createEmptyMovieClip("logo_mc", 999);
loadMovie("test2.jpg", logo_mc);
trace (logo_mc.width);
trace (logo_mc.height);
This doesn't work. I gives undefined. I've read that first I would have to let Flash know that the jpg has been fully loaded. How would I do that? I've tried using getBytesLoaded/getBytesTotal, but then it gives 0 for both getBytes.
Also used stuff like this, but that doesn't work either:
Code:
this.createEmptyMovieClip("logo_mc", 999);
loadMovie("test2.jpg", logo_mc);
logo_mc.onLoad = function() {
trace (logo_mc.width);
trace (logo_mc.height); }
How do I check whether the jpg has been fully loaded before I can show/alter it's dimensions?
-
FK'n_dog
have a look in the Help files for the MovieClipLoader class
MovieClipLoader.onLoadInit event listener
When this listener has been invoked, you can set properties,
use methods, and otherwise interact with the loaded movie.
-
Yes, already found that one. Still, I was wondering if something like that could also be done using createEmtpyMovieclip and LoadMovie. Thought of something myself (see below). Is that the way this previously was done? Or is there a more efficient way of doing this using LoadMovie?
Code:
this.createEmptyMovieClip("logo_mc", 999);
loadMovie("test2.jpg", logo_mc);
this.onEnterFrame = function() {
if (logo_mc.getBytesTotal() != false) {
if (logo_mc.getBytesLoaded() == logo_mc.getBytesTotal()) {
trace(logo_mc._width);
trace(logo_mc._height);
delete this.onEnterFrame;
}
}
};
-
FK'n_dog
an empty movieclip has zero width and height
you can check for these properties in an OEF loop
PHP Code:
this.createEmptyMovieClip("logo_mc", 999);
loadMovie("test2.jpg", logo_mc);
this.onEnterFrame = function() {
trace(logo_mc._width);
if (logo_mc._width > 0) {
trace(logo_mc._width);
delete this.onEnterFrame;
}
};
-
And this width/height is only set if the image to be loaded has been fully loaded inside the first empty movieclip? So while it's loading it is still regarded as an empty clip with dimensions 0?
-
FK'n_dog
the external file must load into and instanciate the movieclip
before its properties are able to be accessed.
best practice is to use the MovieClipLoader.onLoadInit event,
which is called after the content is loaded and fully initialized.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|