You're loading an outside jpg into Flash. The player needs a moment
not only to load the entire image, but also to parse/convert/love the
file and display it in Flash. It shouldn't take a full second for
this happen, but can take anywhere from one to a few frames (depends
on image size, number of images, etc).
Simply write a basic loop, based on holderClip._width, that loops
until the width is no longer 0. This should be a separate loop/test
from .getBytesTotal since you want to be sure its actually fully
loaded first before you lock up your app in this kind of loop.
-radley
On Dec 8, 2005, at 9:42 AM, Mike Boutin wrote:
Can anyone tell me why when I call the displayImage() function
after I fully loaded, and try to get the _width and _height of
holderClip, it comes back as zero. But if I wait 1 second after
the load and run the displayImage() function through the button
click, it then finds the width and height.
#include "lmc_tween.as"
var num:Number = 1;
var space:Number = 20;
function loadImage(){
holderClip.loadMovie(num+".jpg");
//holderClip._alpha = 0;
this.onEnterFrame = function(){
var lvBytesLoaded:Number = holderClip.getBytesLoaded();
var lvBytesTotal:Number = holderClip.getBytesTotal();
var percent = (lvBytesLoaded/lvBytesTotal)*100;
if (lvBytesLoaded == lvBytesTotal) {
trace("Image" + num + " loaded.");
displayImage();
delete this.onEnterFrame;
}
}
}
function displayImage():Void {
//Image is not loaded.
var w = holderClip._width + space;
trace("Image width: "+holderClip._width);
trace("Image new width: "+w);
var h = holderClip._height + space;
trace("Image height: "+holderClip._height);
trace("Image new height: "+h);
/*
//Fade in Image / resize border
holderClip.tween("_alpha", 100, 2, "easeOut");
border.tween("_width", w, 1, "easeOutElastic");
border.tween("_height", h, 1, "easeOutElastic");
*/
}
myButton.onRelease = function(){
displayImage();
}
//Start it up!
loadImage();
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
------------------------------------------------------------------------
------
Radley Marx
[EMAIL PROTECTED]
310.220.4088
http://www.radleymarx.com
------------------------------------------------------------------------
------
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders