about:flash

Friday, June 10, 2005

For .jpg, check _height instead of getBytesLoaded()

While checking whether any .jpg is loaded or not, it's good to check _height of the container mc instead of getBytesLoaded().
Because, though .jpg loaded fully, it may not be rendered on the screen. So if you want to get the the properties like height/width immediatly after loading, you may get 0.

mcContainer.load("sample.jpg");
this.onEnterFrame = function(){
var val = mcContainer._height;
if(val > 0){
delete this.onEnterFrame;
foo();
}
}

Be careful while using above logic to check .swf loading, since, if the first frame of the .swf being loaded is blank with stop() written on it then, mcContainer._height always written 0 & it will become a endless loop.

2 Comments:

Post a Comment

<< Home