Hi all,
Quick question regarding arrays...
Is there any secret in creating an array of DynLayers and incrementing
through them...
I am using some base code from Richard's Tree stuff.
Here's the code that I have:
==========
this.items=new Array;
this.counter=0;
this.selectorHeight=18;
object.prototype.add=function(strHTML){
var i = this.items.length;
this.items[i] = new
DynLayer(null,0,this.counter*this.selectorHeight,this.w,this.selectorHeight)
;
this.items[i].setHTML(strHTML);
this.counter++;
}
object.prototype.readyForAction=function() {
alert(this.items.length);
/*
this.addChild(this.items[0]);
this.addChild(this.items[1]);
this.addChild(this.items[2]);
*/
for (i=0; i<this.items.length; i++) {
alert(i);
this.addChild(this.items[i]);
//setTimeout(this.addChild(this.items[i]), 1000);
}
}
==========
On my calling page I have:
tf=new object();
tf.add("HTML1");
tf.add("HTML2");
tf.add("HTML3");
tf.readyForAction();
==========
Questions:
1. Refer to the code under the function readyForAction ... the first alert
correctly gives me the number of items (in this case, 3). The commented out
tags give me what I need (this.addChild(this.items[0] ... [2]). But
obviously, this is not going to work very dynamically. I have a for loop
that "in theory" does the same thing as the commented out "addChild"s. When
I run the readyForAction function, the following occurs:
- alert(0);
- this.addChild(this.items[0]);
- alert(1);
- this.addChild(this.items[1]);
- alert(1);
- this.addChild(this.items[1]);
... and it pretty much cycles through the alert(1) and never goes through
the other items in the array and I have to pretty much close down the
browser from Task Manager to end the looping JavaScript alerts...
... I also tried putting a setTimeout function (bad, bad hack) but that
didn't help.
... any ideas on why the for loop won't go after the second addChild (and
therefore, also not end the loop).
Thanks,
Chris
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/mailman/listinfo/dynapi-help