Results 1 to 3 of 3

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

  1. #1
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default Simple XML thing I made, images don't show on first run?

    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:

    Code:
    //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.

  2. #2
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    Got it working. In case anybody stumbles across this, the problem turned out to be with the resizing happening every frame.

  3. #3
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    Here's the revised code that works perfectly. ^_^

    Code:
    //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;
    		}
    	}
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •