# Load jpg + preloader and fade in/out

**URL:** <https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674>\
**Category:** Uncategorized\
**Created:** [August 20, 2004, 2:27pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674 "2004-08-20T14:27:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatnslow](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@fatnslow](https://forum.kirupa.com/u/fatnslow)\
**Post date:** [August 20, 2004, 2:27pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/1 "2004-08-20T14:27:10Z")

</div>

Hey, I would like an combobox to load jpg’s into a container when a value is selected, and with fade out and in when a photo is change, and if possible a percent preloader.

I have this as to make the combobox load swf’s, but could anyone please be so kind to make it so it loads jpg’s with fade in and out and percent loader? :

```auto

// ComboBox
function handler() {
 chosen = _root.combobox.getSelectedItem().label;
 if (chosen == "Lagbilde") {
  _root.container.loadMovie("sound.swf");
 } else if (chosen == "Celluoid Dream") {
  _root.container.loadMovie("sound2.swf");
 } else if (chosen == "God Called In Sick Today") {
  _root.container.loadMovie("sound3.swf");
 } else if (chosen == "Fun, Fun, Fun") {
  _root.container.loadMovie("sound4.swf");
 }
}

```

Thanks in advance,  
fatnslow

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 21, 2004, 7:00am UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/2 "2004-08-21T07:00:27Z")

</div>

hey , there was an excellent discussion about a resizing gallery that faded jpgs in. do a search in the forums for it. if you cant figure it out let me know and ill send you my code that i ended up using on [www.creativejuggernauts.com/daniel](http://www.creativejuggernauts.com/daniel)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 21, 2004, 10:10am UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/3 "2004-08-21T10:10:05Z")

</div>

Nice, but I have allready made something that fits my site, but it doesn’t work. See, I have 2 comboboxes that when you select one of the value’s it loads a jpg into a container, but it doesn’t work when I have the whole photo.swf loaded into main.swf, and the comboboxes get all white and looks weird, heres the as im using:

```auto

this.pathToPics = "bilder/";
this.pArray = ["image0.jpg", "image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg"];
this.fadeSpeed = 20;
MovieClip.prototype.changePhoto = function(d) {
 this.pIndex = d;
 this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
 if (this.photo._alpha>this.fadeSpeed) {
  this.photo._alpha -= this.fadeSpeed;
 } else {
  this.loadPhoto();
 }
};
MovieClip.prototype.loadPhoto = function() {
 var p = this.photo;
 p._alpha = 0;
 p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
 this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
 var i, l, t;
 l = this.photo.getBytesLoaded();
 t = this.photo.getBytesTotal();
 if (t>0 && t == l) {
  this.onEnterFrame = fadeIn;
 } else {
  // trace(l/t);
 }
};
MovieClip.prototype.fadeIn = function() {
 if (this.photo._alpha<100-this.fadeSpeed) {
  this.photo._alpha += this.fadeSpeed;
 } else {
  this.photo._alpha = 100;
  this.onEnterFrame = null;
 }
};
// LOAD
_root.changePhoto(0);
// ***CB 1
formStyleFormat = new FStyleFormat();
formStyleFormat.textFont = "FFF Harmony";
formStyleFormat.textSize = "9";
formStyleFormat.addListener(comboBox);
//***CB 2
formStyleFormat = new FStyleFormat();
formStyleFormat.textFont = "FFF Harmony";
formStyleFormat.textSize = "9";
formStyleFormat.addListener(comboBox2);
// ComboBox
function handler() {
 chosen = _root.combobox.getSelectedItem().label;
 if (chosen == "Lagbilde") {
  _root.changePhoto(0);
 }
}
// ComboBox 2
function handler2() {
 chosen = _root.combobox2.getSelectedItem().label;
 if (chosen == "Axel") {
  _root.changePhoto(1);
 } else if (chosen == "Idol Arne") {
  _root.changePhoto(2);
 } else if (chosen == "Vaske Stian") {
  _root.changePhoto(3);
 }
}

```

and if anyone could insert a percent preloader fior each image I would super happy.

Thanks in advance,  
fatnslow

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2004, 9:18am UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/4 "2004-08-22T09:18:19Z")

</div>

Anyone able to help me here?

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2004, 5:06pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/5 "2004-08-22T17:06:39Z")

</div>

The preloader is allready there…look for the loadMeter proto.  
It’s not working cause you’re using \_root;)

scotty(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 22, 2004, 11:20pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/6 "2004-08-22T23:20:33Z")

</div>

What should I use instead of \_root? And how do I get the loader to show? put in a textfield with some var?

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 23, 2004, 6:50am UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/7 "2004-08-23T06:50:43Z")

</div>

With a little search;)  
The \_root issue has been answered a zillion times eg  
[http://www.kirupaforum.com/forums/showthread.php?t=66037](http://www.kirupaforum.com/forums/showthread.php?t=66037)  
or do a search on “standalone”, “\_root” etc…  
for the preloader:  
[http://www.kirupaforum.com/forums/showthread.php?t=66179](http://www.kirupaforum.com/forums/showthread.php?t=66179) [size=1]post#5[/size]

scotty(-:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 23, 2004, 8:32pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/8 "2004-08-23T20:32:08Z")

</div>

Hey thanks, got it fixed now, just had overlooked 2 \_root.'s somewhere in there. But when I view my .swf online, the combobox get all weird, it has white instead of text, and the select highlight is all white, so you cant see the text you select. Anyone know how to fix that?

[http://www.vsf-fc.tk](http://www.vsf-fc.tk) , then go to “bilder”. The enter button doesnt work for someone, no idea why, but if so, just click the link under.

Thanks,  
fatnslow

Th

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 24, 2004, 3:53pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/9 "2004-08-24T15:53:44Z")

</div>

Anyone ble to help please?

Thanks,  
fatnslow

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2004, 6:35am UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/10 "2004-08-25T06:35:52Z")

</div>

i’m trying to do the same sort of thing.  
shouldn’t this code work to wait until something is loaded before continuing?

```auto
if (clippy.getBytesTotal() > 0 && getBytesLoaded() == getBytesTotal()){
	trace("* * * LOADED * * *");
	this.gotoAndPlay(39);
} else {
	this.gotoAndPlay("loadaniloop");
	}

```

well it seems to work fine when testing locally, but when it is published to the web, it hits the “\* \* \* LOADED \* \* \*” instructions before the clip is actually loaded.

i’m loading in a jpeg, BTW.

any suggestions?  
thanks,  
david

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 25, 2004, 1:41pm UTC](https://forum.kirupa.com/t/load-jpg-preloader-and-fade-in-out/61674/11 "2004-08-25T13:41:49Z")

</div>

Sry, cant help. But still need some help on my combobox…

thanks in advance
