Question : 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...
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
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 Select All

Answer : What's wrong with this script?

i was thinking simply preloading all the images and then display them in a timed pattern.

P.S i think this is what the dude in the other question wants

he need to know you cant address a instance my a name you dont know!


var square:Square = new Square();
var circle:Circle = new Circle();

addChild(square);

square.addChild(circle);



click_btn.buttonMode = true;
click_btn.addEventListener(MouseEvent.CLICK, clickButton);

function clickButton(event:MouseEvent):void {
   trace(square.name);//
    trace(circle.name);//
   square.removeChild(circle);
}

Random Solutions  
 
programming4us programming4us