Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seamless Playback of External, Dynamically-Loaded JPEGs

Status
Not open for further replies.

ajbufort

Programmer
Apr 4, 2004
50
US
Hi Guys,

I've been at this for a while, and I am afraid I am still quite the newbie when it comes to Flash.

I want to use Flash as the GUI for a (near real-time) screen capture viewer. I want a user to be able to transmit screen captures of their screen on one end, and on the other, have someone with my Flash movie in their browser be able to see the captures as they are coming from the other person's machine. I am writing an app in Delphi to do the captures and broadcasting. Currently, the images are saved on a server, the server from which I will be pulling these JPEGs and placing them dynamically in the Flash piece.

Basically, all I want is some Flash that will read in a series of numbered images (image_01.jpg, image_02.jpg, etc.), and display them, one at a time, without delays inbetween and without flicker of any kind - indefinitely. I have read of preloading images off stage and what not, but I am still not implementing this right. And also, I want to understand how to do it correctly and efficiently, not just make it work any which way.

I am thinking there is going to have to be some sort of delay BEFORE the first image is shown, to build up a decent amount of images to pull from on the server.

Can anyone out there give me some feedback on this? Some code that can get me to where I am trying to go?

Thanks,

-Tony
 
You way you're going will work. There will be a delay while the image loads into the Flash movie but after that it will be easy to access it instantly. Loading the images into offstage locations and then bringing them into the visible area is a decent solution to the problem.

Here is some code that does that for one image, you just need to add a loop to call multiple images. Using the 'enterFrame' structure means you can add in things like loading bars etc if you want to and they will animate smoothly.

Code:
loadImage = function (img) {
	_root.createEmptyMovieClip('loadPoint', 1);
	with (loadPoint) {
		// load image into location offstage
		loadMovie('images/'+img+'.jpg');
		_x = 1000;
		_y = 1000;
	}
	loadPoint.onEnterFrame = function() {
		// work out how much of image has loaded
		var percent = this.getBytesLoaded()/this.getBytesTotal()*100;
		if (percent>=100 && percent != Number.NaN) {
			// image is loaded so show it and cancel loading process
			showImage(this);
			delete this.onEnterFrame;
		}
	};
};
//
showImage = function (clip) {
	clip._x = 0;
	clip._y = 0;
};
//
loadImage('test');
//
stop();
 
Very cool, thanks Wangbar. I actually worked out the problem myself using another technique involving four keyframes and a loop between frames 2 through 4 that alternately loads a jpeg in each frame and flips between them. So for instance, 2 loads an image, delay, then 3 loads an image, delay, then 4 calls 2 again, and so on. Works like a charm.

-Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top