Log in

View Full Version : Simple XML thing I made, images don't show on first run?



jlizarraga
09-14-2008, 04:16 PM
Hi all,

I've attached the FLA for inspection.

Basically there are four tabs (the last one isn't loaded from XML and its contents haven't been created yet), and clicking on a tab loads a small amount of XML. Everything is working fine, but the first time an image is requested it doesn't want to display. Also, clicking the tabs really fast for a few seconds can cause all the images to vanish as well.

Inserting some trace actions (which have since been removed) revealed that when the images are not showing, Flash reports their containing MC as being visible and having full opacity, which are the properties being manipulated to fade in and display the images, so I'm stumped.

Here's the bit of code that handles the image loading:


//Image fading and resize functions.
function loadIMG(obj) {
var filesize = obj.photoWrap.photoMC.getBytesTotal();
var loaded = obj.photoWrap.photoMC.getBytesLoaded();
if (loaded != filesize) {
obj.photoWrap.preloaderMC._visible = true;
} else {
var photoW = obj.photoWrap.photoMC._width;//Width
var photoH = obj.photoWrap.photoMC._height;//Height
var photoR = photoW/156;//Ratio
var photoO = (117-photoH)/2;//Top Offset
obj.photoWrap.photoMC._width = 156;//Set width to 156
obj.photoWrap.photoMC._height = photoH/photoR;//Set corresponding height
obj.photoWrap.photoMC._y = (-(117/2))+photoO;//Vertically center image
obj.photoWrap.preloaderMC._visible = false;
if (obj.photoWrap.photoMC._alpha<100) {
obj.photoWrap.photoMC._alpha += 2;
}
}
}

Thanks for any replies! Please check out the attached file to get a better idea of what might be going wrong.

jlizarraga
09-15-2008, 06:43 AM
Got it working. In case anybody stumbles across this, the problem turned out to be with the resizing happening every frame.

jlizarraga
09-15-2008, 07:18 AM
Here's the revised code that works perfectly. ^_^


//Image fader.
function loadIMG(obj) {
var filesize = obj.photoWrap.photoMC.getBytesTotal();
var loaded = obj.photoWrap.photoMC.getBytesLoaded();
if (loaded != filesize) {
obj.photoWrap.preloaderMC._visible = true;
} else {
obj.photoWrap.preloaderMC._visible = false;
if (obj.photoWrap.photoMC._width != 156 && obj.photoWrap.photoMC._width != 0) {
var photoW = obj.photoWrap.photoMC._width;//Width
var photoH = obj.photoWrap.photoMC._height;//Height
var photoR = photoW/156;//Ratio
obj.photoWrap.photoMC._width = 156;//Set width to 156
obj.photoWrap.photoMC._height = photoH/photoR;//Set corresponding height
var photoO = (117-obj.photoWrap.photoMC._height)/2;//Top Offset
obj.photoWrap.photoMC._y = (-(117/2))+photoO;//Vertically center image
}
if (obj.photoWrap.photoMC._alpha<100) {
obj.photoWrap.photoMC._alpha += 5;
}
}
}