On Mar 22, 8:42 pm, "00steve" wrote:
> Hi, I am attempting to create a script in which object A contains an
> array of "objectb" objects. An overview of the code is posted below.
> When I attempt to access "myObjArr" array like this:
>
> alert(test1.myObjArr[0].a);
>
> I get the error "myObjArr is undefined". I was wondering if anyone
> could help.
> Thanks.
>
> test1 = new objectA(x,y);
> test1.addObj(a,b,c);
>
> alert(test1.myObjArr[0].a); //generates error
>
> function objectA(x,y) {
>
> this.addObj = addObj;
> this.myObjArr = new Array();
>
> function objectB(a,b,c) {
> this.a =a;
> }
>
> function addObj() {
> myObjArr[myObjArr.length] = new objectB(a,b,c);
>
> }
> }
That looks a bit confused. Try:
--
Rob
|