Another goofy MX quesiton regardng preloading for external JPEG's

I want to preload, and possibly use a transition to bring the image into focus once loaded… I assume I use the same idea as a preloader for a movie, but need a little guidence?

Ok, got the image to load dynamically on a button press, now I’d like to know how I’d go about having a ‘loading bar’ icon for larger images that I’ll be displaying…

No one?

Nope, I don’t know. I tried it once before and all mine would do is say 0% then stay there then say 100% and show the picture, so it was pretty useless.

Sorry man.

I don’t understand your question :beam:

  1. Did you solve that “Come into focus” thing?
  2. What do you mean a ‘Loading Bar’ icon? Are you talking about a preloader for you jpegs?

I believe they mean a preloader for your dynamically loaded .jpg images. Where it shows a preloader bar in place of the empty area that normally shows and then shows the image when it is done loading.

Note: I would be INCREDIBLY grateful if you could answer this one Ilyas. As I said about my last one, it failed miserably and I couldn’t figure it out, it drove me nuts! And I am really looking for one for something I want to do.

Well, it’s no different from an swf preloader :trout:

If you have a container clip in your timeline, something like this should work:

this.createEmptyMovieClip("preloader",1000);
container.loadMovie("myJPG.jpg");
container._visible=false;
preloader.onEnterFrame=function(){
  var l=container.getBytesLoaded();
  var t=container.getBytesTotal();
  if (l > 0 && l >= t){
    container._visible=1;
    delete this.onEnterFrame;
  }
  else {
    // stuff with your loading bar
  }
}

Am I answering your question? [SIZE=1]sorry if I’m not, it’s still early here :P[/SIZE]

It is early here too… 4am. This sounds right though, thanks. For some reason I tried something just like this but it didn’t work. I want to try it again now.

Get some sleep first :stuck_out_tongue:

Me? Sleep? Whats that?!?!?!

Anywho, it isn’t working. It says that container is undefined in the trace window. Now that I have a base (that looks almost exactly like what I had before :slight_smile: I will keep at it.

And yes… i know container is a clip I have to make… before you say something smart…lol.

HEHEHE… got it. ■■■■ typos… switch some letters and it doesn’t want to work. What is up with that!?!.. :trout: <-- to me.

Thanks guys, and yes that’s exactly what I was looking for, sorry I didn’t explain it more.

I’ll try this tommorow!

:slight_smile:

Come on people, let’s all :trout: Lost!

:evil:

Allright a ceremonius trout slapping for beta!

:trout::trout: :slight_smile:

may i paticipate? :trout: :trout: :trout:

But, ■■■■ lost…you are one creative mofo, ill be looking for your name in the future, keep up the good work :trout:

hehehe, I almost forgot about my stupid mistake :trout:

And thanks fade-away :slight_smile:

Ok, maybe I’m a bit in over my head, could someone show me how you go about placing the loading bar?

A sample FLA would be greatly appreciated.

Mucho thx.

this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 1001);
container.loadMovie("yourImage.jpg");
container._visible = false;
preloader.onEnterFrame = function() {
	var l = container.getBytesLoaded();
	var t = container.getBytesTotal();
	var getPercent = l/t;
	loadText = Math.round(getPercent*100)+"%";
	loadBar._width = getPercent*100;
	if (l>0 && l>=t) {
		container._visible = 1;
		delete this.onEnterFrame;
	}
};

That is the code I used.

loadText is a dyanmic textbox on the stage with the VAR name (not instance name) of “loadText” and it shows the percent loaded.

loadBar is a movie clip on the stage with the instance name “loadBar” and its width increases depending on the amount loaded (note: change the 100 in this line to the final width of your loadBar clip).

EDIT: Here is my code in action. VIEW HERE

Thanks!!

I noticed it doesn’t cache the image? Seems to reload each time.

Ok, still a little lost, what am I doing wrong?


button.onPress = function () {
	this.createEmptyMovieClip("preloader", 1000);
	this.createEmptyMovieClip("container", 1001);
	container.loadMovie("test.jpg");
//  container._x = 250 ;
//	container._y = 0 ;
	container._visible = false;
	preloader.onEnterFrame = function() {
	   	var l = container.getBytesLoaded();
	    var t = container.getBytesTotal();
	    var getPercent = l/t;
//	    loadText = Math.round(getPercent*100)+"%";
	    loadBar._width = getPercent*500;
	    if (l>0 && l>=t) {
  	        container._visible = 1;
    	    delete this.onEnterFrame;
   		}
	}
};