Link to home
Start Free TrialLog in
Avatar of Dreammonkey
DreammonkeyFlag for Belgium

asked on

What's wrong with this script?

What's wrong with this script?
It crashes in IE, not in FireFox.

XML loading code is left out...
var imageTimer:Timer = new Timer(10000);
imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
imageTimer.start();
 
var imageCount:int = -1;
function onNewImage(e:Event):void {
	//trace("load New Image");
	if (imageCount < images.length-1) {
		imageCount++;
	} else {
		imageCount = 0;
	}
	var nextImageURL:String = images[imageCount].url;
	var nextImageTEXT:String = images[imageCount].name;
 
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
	imageLoader.load(new URLRequest(nextImageURL));
	function onImageLoad(evt:Event):void {
		var loader:Bitmap = Bitmap(evt.target.content);
 
		var resizeHeight:uint = 250;
		var resizeWidth:uint = 375;
		
		//Resize the images
		if (loader.width > loader.height) {
			// RESIZE WIDTH
			var diff:Number = loader.width - resizeWidth;
			//trace("diff: "+diff);
			var perc:Number = (loader.width - diff )/loader.width*100;
			//trace("perc: "+perc);
			loader.scaleX = loader.scaleY = perc/100;
			//Position Y
			loader.y = resizeHeight/2 - loader.height/2;
		} else if (loader.width < loader.height) {
			// RESIZE HEIGHT
			var ddiff:Number = loader.height - resizeHeight;
			//trace("ddiff: "+ddiff);
			var pperc:Number = (loader.height - ddiff )/loader.height*100;
			//trace("pperc: "+pperc);
			loader.scaleX = loader.scaleY = pperc/100;
			//Position X
			loader.x = resizeWidth/2 - loader.width/2;
		}
		imagePlayer.imageHolder.addChild(loader);
		imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
		
		if (imagePlayer.imageHolder.numChildren >= 2) {
			var bo:Object = imagePlayer.imageHolder.getChildAt(1);
			var oldbo:Object = imagePlayer.imageHolder.getChildAt(0);
			//trace(bo);
			bo.alpha = 0;
			Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:remove});
			//if (imagePlayer.imageHolder.numChildren != 1) {
			Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
			function remove():void {
				imagePlayer.image_txt.text = nextImageTEXT;
				if (imagePlayer.imageHolder.numChildren != 0) {
					imagePlayer.imageHolder.removeChildAt(0);
				}
			}
		}
	}
}

Open in new window

error.jpg
Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

hello

1. does the error appear on every computer running I.E. if yes how many computers have you tested so far!

2. would you be able to supply some of the xml.( without any of your personal data).

GE
Avatar of Dreammonkey

ASKER

Hi Greeneel,

It seems to happen on other computers as well, so far I've tested it on 2 machines. Could it be a cache issue? Every time a photo gets loaded it gets loaded from the server (this is normal), but once all the photos have been displayed once it starts again from scratch. I think this surely isn't the best way to do this right? Should I try to find a way to keep the images in the DisplayList ?

I wrote the code myself, it was my first go at making an image loader in as3.
Could you comment about the code (like things you would do differently...)

Thanks for the help, I hope we can find the solution because it is rather urgent...

PS: I already posted this question last week, but had few response :
Q_24066747 (Double points...?)

<? XML version="1.0" encoding="utf-8" ?>
<root>
	<images>
		<image id="1" name="name 1" url="photos/1.jpg"/>
		<image id="2" name="name 2" url="photos/2.jpg"/>
		
	</images>
</root>

Open in new window

if the first image is not finished loading with the 10 secs does the program still call for the next image to begin loading?
I think it does, how could I correct this?

make a variable that says imageloaded = true?
with and if statement in the onLoadImage function ?

PS: I changed code in lines 56 - 61 to cofe in snippet:
First I thought this had solved it, it seems to run much longer now, but still it crashed after a while....
function remove():void {
	imagePlayer.image_txt.text = nextImageTEXT;
	if (imagePlayer.imageHolder.numChildren != 0) {
		imagePlayer.imageHolder.removeChild(oldbo);
		oldbo = null;
	}
}

Open in new window

did you stop the timer while the new images load.
and start it again when the load is complete?

i will prepare an example to show you how i do the same task.

I hadn't thought of that... interesting, I'm looking forward to your code .

I did add a Boolean 'loading' ...

In the snippet is the code I'm using now, so far it hasn't yet crashed...

correction, it just crashed while opening a new tab in the explorer window...


var imageTimer:Timer = new Timer(10000);
imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
imageTimer.start();
 
var loading:Boolean = false;
 
var imageCount:int = -1;
function onNewImage(e:Event):void {
	//trace("load New Image");
	if (loading == false) {
		loading = true;
		if (imageCount < images.length-1) {
			imageCount++;
		} else {
			imageCount = 0;
		}
		var nextImageURL:String = images[imageCount].url;
		var nextImageTEXT:String = images[imageCount].name;
 
		var imageLoader:Loader = new Loader();
		imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
		imageLoader.load(new URLRequest(nextImageURL));
		function onImageLoad(evt:Event):void {
			loading = false;
			var loader:Bitmap = Bitmap(evt.target.content);
 
			var resizeHeight:uint = 250;
			var resizeWidth:uint = 375;
 
			//Resize the images
			if (loader.width > loader.height) {
				// RESIZE WIDTH
				var diff:Number = loader.width - resizeWidth;
				//trace("diff: "+diff);
				var perc:Number = (loader.width - diff )/loader.width*100;
				//trace("perc: "+perc);
				loader.scaleX = loader.scaleY = perc/100;
				//Position Y
				loader.y = resizeHeight/2 - loader.height/2;
			} else if (loader.width < loader.height) {
				// RESIZE HEIGHT
				var ddiff:Number = loader.height - resizeHeight;
				//trace("ddiff: "+ddiff);
				var pperc:Number = (loader.height - ddiff )/loader.height*100;
				//trace("pperc: "+pperc);
				loader.scaleX = loader.scaleY = pperc/100;
				//Position X
				loader.x = resizeWidth/2 - loader.width/2;
			}
			imagePlayer.imageHolder.addChild(loader);
			imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
 
			if (imagePlayer.imageHolder.numChildren >= 2) {
				var bo:Object = imagePlayer.imageHolder.getChildAt(1);
				var oldbo:Object = imagePlayer.imageHolder.getChildAt(0);
 
				bo.alpha = 0;
				Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:remove});
				Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
 
				function remove():void {
					imagePlayer.image_txt.text = nextImageTEXT;
					if (imagePlayer.imageHolder.numChildren != 0) {
						imagePlayer.imageHolder.removeChild(oldbo);
						oldbo = null;
					}
				}
			}
		}
	}
}

Open in new window

please take note of how the thumbs are loaded.
this is an old project i worked on a while back but the basic idea is there




http://dl.getdropbox.com/u/45567/loadimages.rar
Greeneel,

Thanks for the fla. It seems like a nice peace work. However I get the impression, correct me if I'm wrong, that the way you are loading the main Images doesn't defer that much from the way I'm doing it. Except of course your getMainImage() gets triggered by a MouseEvent while my onNewImage() gets triggered by the Timer()...

Earlier you mentioned  :
===>did you stop the timer while the new images load.
and start it again when the load is complete?<===

I tried this in the code below but still the explorer crashes...
I'm really clueless about what's happening...

var imageTimer:Timer = new Timer(10000);
imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
imageTimer.start();
 
 
var imageCount:int = -1;
function onNewImage(e:Event):void {
	//trace("load New Image");
	imageTimer.stop();
	if (imageCount < images.length-1) {
		imageCount++;
	} else {
		imageCount = 0;
	}
	var nextImageURL:String = images[imageCount].url;
	var nextImageTEXT:String = images[imageCount].name;
 
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
	imageLoader.load(new URLRequest(nextImageURL));
	function onImageLoad(evt:Event):void {
		imageTimer.start();
		var loader:Bitmap = Bitmap(evt.target.content);
 
		var resizeHeight:uint = 250;
		var resizeWidth:uint = 375;
 
		//Resize the images
		if (loader.width > loader.height) {
			// RESIZE WIDTH
			var diff:Number = loader.width - resizeWidth;
			//trace("diff: "+diff);
			var perc:Number = (loader.width - diff )/loader.width*100;
			//trace("perc: "+perc);
			loader.scaleX = loader.scaleY = perc/100;
			//Position Y
			loader.y = resizeHeight/2 - loader.height/2;
		} else if (loader.width < loader.height) {
			// RESIZE HEIGHT
			var ddiff:Number = loader.height - resizeHeight;
			//trace("ddiff: "+ddiff);
			var pperc:Number = (loader.height - ddiff )/loader.height*100;
			//trace("pperc: "+pperc);
			loader.scaleX = loader.scaleY = pperc/100;
			//Position X
			loader.x = resizeWidth/2 - loader.width/2;
		}
		imagePlayer.imageHolder.addChild(loader);
		imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
 
		if (imagePlayer.imageHolder.numChildren >= 2) {
			var bo:Object = imagePlayer.imageHolder.getChildAt(1);
			var oldbo:Object = imagePlayer.imageHolder.getChildAt(0);
 
			bo.alpha = 0;
			Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:remove});
			Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
 
			function remove():void {
				imagePlayer.image_txt.text = nextImageTEXT;
				if (imagePlayer.imageHolder.numChildren != 0) {
					imagePlayer.imageHolder.removeChild(oldbo);
					oldbo = null;
				}
			}
		}
	}
}

Open in new window

do you have a link to a url so i can see the project working.

can i see the project?
Sure !

www.jazz-combo.be is the main website

The photo app gets loaded into the main fla.
You can check that out here :

www.jazz-band.be/photo/
or
www.jazz-band.be/photo/photo.swf

I'll temporarily put the .fla in the same directory...
i have been running your photo sldeshow since i got it and it has yet to crash or act in any other manner than change the pics
its running in firefox , chrome, i.e and opera.
and no crashes.

clear your i.e Cache
all 4  explorers are still running no crashes
i am using 4 different computers all have your sideshow opened in IE
Ok this is bizar,

By clearing cache you mean emptying your temporary internet files folder?
That's what I just did but the error is persistent...

What version of IE are you using? mine is IE7

Have you tried opening new tabs in the explorer while the photo app is running?

I'd like to believe the problem isn't code related, but If I have the problem, most likely other people will experience the same + I tested it this afternoon on my girlfriend's machine where the exact same error occurred, It was the first time the app got loaded on here machine...

i have IE 7 also
OK,

I closed all my IE windows went to config panel=>IE properties
cleared my temp files, cookies, and browse history.

When I started above sentence, I thought this sentence was going to bring the good news, while I was writing the sentence above the app crashed...
I had two windows open at the time (this one) and another one playing the main website + the photoapp in another tab.

It had been playing for a long time, so long even I was able to watch Lee Brimelow's latest video tutorial on CS4 in another tab...

I was happy , now I'm desperate...

Could it be both my and my girlfriend's (!) computers are totally screwed?
it's still playing on my computer along with 2 others i can see from where i am. not sure what to say at this point.
the systems i am using are all running XP

we may have to look over the entire code. but i just cant get why i am not seeing the error you are!
                                                                                                           
This one is the strangest I've come accross so far...

I'm using XP as well, SP3

By full code you mean the code of the main fla, or only the rest of the photo app?

Below full photo app code
import caurina.transitions.Tweener;
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// XML LOADER // XML LOADER // XML LOADER // XML LOADER // XML LOADER // XML LOADER // XML LOADER // XML LOADER //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
var XMLLoader:URLLoader = new URLLoader();
XMLLoader.addEventListener(Event.COMPLETE, onXMLload);
XMLLoader.load(new URLRequest("http://www.jazz-band.be/photo/photos.xml"));
//XMLLoader.load(new URLRequest("photos.xml"));
 
var cactusXML:XML;
var images:Array = new Array();
 
function onXMLload(e:Event):void {
	cactusXML = new XML(e.target.data);
 
	//IMAGES
	var imageList:XMLList = cactusXML.images.image;
	for (var i:uint = 0; i<imageList.length(); i++) {
		var id:uint = imageList.attribute("id")[i];
		var name:String = imageList.attribute("name")[i];
		var url:String = imageList.attribute("url")[i];
		images.push({id:id, name:name, url:url});
		//trace("Image: id: "+id+" name: "+name+" url: "+url);
		//trace(images[i].url);
	}
	trace("PHOTO XML loaded");
	//imagePlayer.image_txt.text = "PHOTO XML loaded";
	onNewImage(e);
	XMLLoader.removeEventListener(Event.COMPLETE, onXMLload);
}
 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
var imageTimer:Timer = new Timer(10000);
imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
imageTimer.start();
 
 
var imageCount:int = -1;
function onNewImage(e:Event):void {
	//trace("load New Image");
	imageTimer.stop();
	if (imageCount < images.length-1) {
		imageCount++;
	} else {
		imageCount = 0;
	}
	var nextImageURL:String = images[imageCount].url;
	var nextImageTEXT:String = images[imageCount].name;
 
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
	imageLoader.load(new URLRequest(nextImageURL));
	function onImageLoad(evt:Event):void {
		imageTimer.start();
		var loader:Bitmap = Bitmap(evt.target.content);
 
		var resizeHeight:uint = 250;
		var resizeWidth:uint = 375;
 
		//Resize the images
		if (loader.width > loader.height) {
			// RESIZE WIDTH
			var diff:Number = loader.width - resizeWidth;
			//trace("diff: "+diff);
			var perc:Number = (loader.width - diff )/loader.width*100;
			//trace("perc: "+perc);
			loader.scaleX = loader.scaleY = perc/100;
			//Position Y
			loader.y = resizeHeight/2 - loader.height/2;
		} else if (loader.width < loader.height) {
			// RESIZE HEIGHT
			var ddiff:Number = loader.height - resizeHeight;
			//trace("ddiff: "+ddiff);
			var pperc:Number = (loader.height - ddiff )/loader.height*100;
			//trace("pperc: "+pperc);
			loader.scaleX = loader.scaleY = pperc/100;
			//Position X
			loader.x = resizeWidth/2 - loader.width/2;
		}
		imagePlayer.imageHolder.addChild(loader);
		imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
 
		if (imagePlayer.imageHolder.numChildren >= 2) {
			var bo:Object = imagePlayer.imageHolder.getChildAt(1);
			var oldbo:Object = imagePlayer.imageHolder.getChildAt(0);
 
			bo.alpha = 0;
			Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:remove});
			Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
 
			function remove():void {
				imagePlayer.image_txt.text = nextImageTEXT;
				if (imagePlayer.imageHolder.numChildren != 0) {
					imagePlayer.imageHolder.removeChild(oldbo);
					oldbo = null;
				}
			}
		}
	}
}

Open in new window

i have run across a few blogs where they say its something with i.e  as to why it works with me and not you!! still wondering
I haven't yet fully read the thread but this is one issue :
both mine and my girlfriend's computer have Norton ???

get rid of it? But then : what about other people using it?
PS: If I disable Norton, then load the .swf would that pinpoint the problem?

Ill try it out anyway...
i just read an article that states when flash tries to connect to external link a runtime error  may happen.

XMLLoader.load(new URLRequest("http://www.jazz-band.be/photo/photos.xml"));
//XMLLoader.load(new URLRequest("photos.xml"));

swap those load vars and see if it helps and use the xml directly from with the folder

its a long shot what what the heck

P.S

one of my systems just got the error
Ok then I at least can be sure it has nothing to do with my computer (if that's a relief...)

Could you post the link to the article you mentioned above?
You're suggesting changing the location of the xml, but this couldn't solve the problem, it gets loaded only once, and the eventListener gets removed after it's fully loaded.

What you're suggesting might work for the location of the images, but if I were to place them all inside the same folder as the .swf things will get messy, I don't like that...

And quite frankly:  "when flash tries to connect to an external link a runtime error can occur"=> this would mean 60% (or more) of all flash apps should produce the same error, I just don't think this is the case...

PS : I do appreciate your efforts on this matter !

you are very right. there has to be something that does not flash as an error but is an error.
would you consider another method of getting the same result done.


P.S  do you need to use?:: import caurina.transitions.Tweener;

I like using it, besides it's recommend by google.code :
http://code.google.com/p/tweener/

I tried messing with the regular tween class, but it found it to be very choppy ...

Your method is more then welcome, as I am afraid the solution to this one is far from being found..
ASKER CERTIFIED SOLUTION
Avatar of Eaddy Barnes
Eaddy Barnes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You're right in both accounts...

Man, I'm loosing grip, however I don't want to take credit for your insight...

thanks for helping me out !
no worries! i am just trying to be a master just like you!

so what do you plan to do?

I'm already a master ;-) not to sure if that's really true...

Well your proposal on preloading all the images sounds like a good idea,
It won't be to hard to rewrite the code I have to get the same result...
+ It 'll be much more efficient regarding bandwidth usage !!!

My guess is to stick to the timer() but only let it handle the tweens using an array or so...

I'll start writing it now, and get back asap.
If that works the points are more then yours !

PS: Another one Im in, way out of my league :
https://www.experts-exchange.com/questions/24084904/How-can-I-store-info-and-attach-it-to-a-sprite.html?cid=238&anchorAnswerId=23471433#a23471433
let me know if you need any help. i am always up for new stuff. i am basically talking on msn at the moment.
Nice approach on the getChildByName question, would've liked seeing the expression on his face when his square moved over 200 pixels to the right all of a sudden ;-)

here it is,

But I'm struggling on the scope of the images now.
Can't get my head straight on what imageCount, bo and oldbo should be when the cicle is round...

I'll get there , but if you want to help be my guess...

PS: do you work in IT ?
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function preload(i:uint):void {
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
	imageLoader.load(new URLRequest(images[i].url));
	function onImageLoad(evt:Event):void {
		var loader:Bitmap = Bitmap(evt.target.content);
 
		var resizeHeight:uint = 250;
		var resizeWidth:uint = 375;
 
		//Resize the images
		if (loader.width > loader.height) {
			// RESIZE WIDTH
			var diff:Number = loader.width - resizeWidth;
			//trace("diff: "+diff);
			var perc:Number = (loader.width - diff )/loader.width*100;
			//trace("perc: "+perc);
			loader.scaleX = loader.scaleY = perc/100;
			//Position Y
			loader.y = resizeHeight/2 - loader.height/2;
		} else if (loader.width < loader.height) {
			// RESIZE HEIGHT
			var ddiff:Number = loader.height - resizeHeight;
			//trace("ddiff: "+ddiff);
			var pperc:Number = (loader.height - ddiff )/loader.height*100;
			//trace("pperc: "+pperc);
			loader.scaleX = loader.scaleY = pperc/100;
			//Position X
			loader.x = resizeWidth/2 - loader.width/2;
		}
		loader.alpha = 0;
		//loader.name = "image"+i;
		trace(loader);
		imagePlayer.imageHolder.addChild(loader);
		trace(imagePlayer.imageHolder.getChildIndex(loader));
		imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
		if (i == 2) {
			startTimer();
		}
		if (i < images.length-1) {
			i++;
			preload(i);
		}
	}
}
 
function startTimer():void {
	trace("timerStart");
	var imageTimer:Timer = new Timer(1000);
	imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
	imageTimer.start();
}
 
 
var imageCount:int = 0;
function onNewImage(e:TimerEvent):void {
	trace("load New Image");
	var oldbo:Object;
	if (imageCount < images.length) {
		imageCount++;
		oldbo = imagePlayer.imageHolder.getChildAt(Number(imageCount));
	} else {
		imageCount = 1;
		oldbo = imagePlayer.imageHolder.getChildAt(Number(images.length));
	}
	var nextImageTEXT:String = images[Number(imageCount-1)].name;
	var bo:Object = imagePlayer.imageHolder.getChildAt(imageCount);
	trace("imageCount: "+imageCount);
	
	trace("imageCount+1: "+Number(imageCount+1));
	//bo.alpha = 0;
	Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:remove});
	Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
 
	function remove():void {
		imagePlayer.image_txt.text = nextImageTEXT;
	}
}

Open in new window

if you tag each instance with a name + a number .
then all you would have to do is fade in the current number and fade out the current number -1

with a if statement in que in case its the first instance is the current number . in this case it will fade out the max number instance.
this way your reference point would be the current number variable.

you get where i am coming from

yes i do work in IT
I tried the .name approach but it doesn't seem to work on the Bitmaps ... (sounds familiar? ;-)  )

Right, I managed to get it fixed using the Sinatra technique...

I even dared uploading it to the server, where it is running right now, and hopefully not crashing within the next couple of days...

One issue, as I want the first image to display right away (meaning while the others are still loading) I added a little code in there to make the first alpha Tween inside the preload function. As a result the first tween is often 'chunky' - is that even a word?

After this one, I'm gonna leave this question RIP

d
sorry code
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function preload(i:uint):void {
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
	imageLoader.load(new URLRequest(images[i].url));
	function onImageLoad(evt:Event):void {
		var loader:Bitmap = Bitmap(evt.target.content);
 
		var resizeHeight:uint = 250;
		var resizeWidth:uint = 375;
 
		//Resize the images
		if (loader.width > loader.height) {
			// RESIZE WIDTH
			var diff:Number = loader.width - resizeWidth;
			//trace("diff: "+diff);
			var perc:Number = (loader.width - diff )/loader.width*100;
			//trace("perc: "+perc);
			loader.scaleX = loader.scaleY = perc/100;
			//Position Y
			loader.y = resizeHeight/2 - loader.height/2;
		} else if (loader.width < loader.height) {
			// RESIZE HEIGHT
			var ddiff:Number = loader.height - resizeHeight;
			//trace("ddiff: "+ddiff);
			var pperc:Number = (loader.height - ddiff )/loader.height*100;
			//trace("pperc: "+pperc);
			loader.scaleX = loader.scaleY = pperc/100;
			//Position X
			loader.x = resizeWidth/2 - loader.width/2;
		}
		loader.alpha = 0;
		//loader.name = "image"+i;
		trace(loader);
		imagePlayer.imageHolder.addChild(loader);
		trace(imagePlayer.imageHolder.getChildIndex(loader));
		imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
		if (i == 0) {
			Tweener.addTween(loader, {alpha:1, time:1, transition:"linear"});
			imagePlayer.image_txt.text = images[0].name;
		}
		if (i == 2) {
			startTimer();
		}
		if (i < images.length-1) {
			i++;
			preload(i);
		}
	}
}
 
function startTimer():void {
	trace("timerStart");
	var imageTimer:Timer = new Timer(10000);
	imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
	imageTimer.start();
}
 
 
var imageCount:int = 1;
function onNewImage(e:TimerEvent):void {
	trace("load New Image");
	var oldbo:Object;
	if (imageCount < images.length) {
		imageCount++;
		oldbo = imagePlayer.imageHolder.getChildAt(Number(imageCount-1));
	} else {
		imageCount = 1;
		oldbo = imagePlayer.imageHolder.getChildAt(Number(images.length));
	}
	var nextImageTEXT:String = images[Number(imageCount-1)].name;
	var bo:Object = imagePlayer.imageHolder.getChildAt(imageCount);
	trace("imageCount: "+imageCount);
	
	trace("imageCount+1: "+Number(imageCount+1));
	//bo.alpha = 0;
	Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:updateText});
	Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
 
	function updateText():void {
		imagePlayer.image_txt.text = nextImageTEXT;
	}
}

Open in new window

try a pre-preloader meaning you get that first image in let it tween in before loading the others. because the task of loading the others while tweening is what probably made the alpha choppy ;)

Good Luck DM

GE

shoot me a message sometimes
was good talking to ya

speraspear@hotmail.com
speraspearpro@yahoo.com
how did it work out?
Solved it,

sorry I didn't get back here any sooner, ...

Thanks for all your help !

PS: we finally got some music online (recorded yesterday), check it out, hope you like it !

the 'final' script :
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // IMAGE LOADER // 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function preload(i:uint):void {
	var imageLoader:Loader = new Loader();
	imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoad);
	imageLoader.load(new URLRequest(images[i].url));
	function onImageLoad(evt:Event):void {
		var loader:Bitmap = Bitmap(evt.target.content);
 
		var resizeHeight:uint = 250;
		var resizeWidth:uint = 375;
 
		//Resize the images
		if (loader.width > loader.height) {
			// RESIZE WIDTH
			var diff:Number = loader.width - resizeWidth;
			//trace("diff: "+diff);
			var perc:Number = (loader.width - diff )/loader.width*100;
			//trace("perc: "+perc);
			loader.scaleX = loader.scaleY = perc/100;
			//Position Y
			loader.y = resizeHeight/2 - loader.height/2;
		} else if (loader.width < loader.height) {
			// RESIZE HEIGHT
			var ddiff:Number = loader.height - resizeHeight;
			//trace("ddiff: "+ddiff);
			var pperc:Number = (loader.height - ddiff )/loader.height*100;
			//trace("pperc: "+pperc);
			loader.scaleX = loader.scaleY = pperc/100;
			//Position X
			loader.x = resizeWidth/2 - loader.width/2;
		}
		loader.alpha = 0;
		//loader.name = "image"+i;
		trace(loader);
		imagePlayer.imageHolder.addChild(loader);
		trace(imagePlayer.imageHolder.getChildIndex(loader));
		imageLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onImageLoad);
		if (i == 0) {
			Tweener.addTween(loader, {alpha:1, time:1, transition:"linear", onComplete:onFirstLoad});
			imagePlayer.image_txt.text = images[0].name;
			
			function onFirstLoad():void {
				i++;
				preload(i);
			}
		} else if ( i < images.length-1) {
			i++;
			preload(i);
		} else if (i == images.length-1) {
			startTimer();
		}
		
	}
}
 
function startTimer():void {
	trace("timerStart");
	var imageTimer:Timer = new Timer(10000);
	imageTimer.addEventListener(TimerEvent.TIMER, onNewImage);
	imageTimer.start();
}
 
 
var imageCount:int = 1;
function onNewImage(e:TimerEvent):void {
	trace("load New Image");
	var oldbo:Object;
	if (imageCount < images.length) {
		imageCount++;
		oldbo = imagePlayer.imageHolder.getChildAt(Number(imageCount-1));
	} else {
		imageCount = 1;
		oldbo = imagePlayer.imageHolder.getChildAt(Number(images.length));
	}
	var nextImageTEXT:String = images[Number(imageCount-1)].name;
	var bo:Object = imagePlayer.imageHolder.getChildAt(imageCount);
	trace("imageCount: "+imageCount);
	
	trace("imageCount+1: "+Number(imageCount+1));
	//bo.alpha = 0;
	Tweener.addTween(bo, {alpha:1, time:1, transition:"linear", onComplete:updateText});
	Tweener.addTween(oldbo, {alpha:0, time:1, transition:"linear"});
 
	function updateText():void {
		imagePlayer.image_txt.text = nextImageTEXT;
	}
}

Open in new window

2 more questions, if I may?

1) on regard on the .name value with the Bitmap Class why doesn't that work?
I've experienced the same with other classes to, do I have to write a class extending the Bitmap Class just to add a variable then?

2) very strange :  I was already using this script (come to think of it...) for a different website. thing is : it never crashed ! The only difference between the two was that the one that never crashed wasn't embedded into another swf ...

d
i did not know you had the gallery withing another swf file.
that could have been a factor.
i guess and this is just a guess . it may have boiled down to how much memory the comp viewing the site had.
i have 4 GB
yes i think you would have to extend it or create a reference point much like the array