arrays - ReferenceError: Error #1069 Actionscript 3 -


so have been stuck on 2 weeks , have no idea how progress.

i have array of movie clips called "_main.speederarray" , i'm trying make if collide each other both destroyed. here code in "speeder class" detect collision.

private function detectionhandler():void{         //trace("array length", _main.speederarray.length);         detectionid = _main.gamecounter;         ( var i:int = _main.speederarray.length -1; >= 0; i--){              var speeder:speeder = _main.speederarray[i];              if(speeder.destroyme) continue;             if(speeder.detectionid == this.detectionid) continue;              if (boxintersect(this, speeder)){                      trace("collision");                      destroyme = true;                     speeder.destroyme = true;             }         }     } 

here boxintersect function code refers to. it's in same class

private function boxintersect ( speeder1:speeder, speeder2:speeder):boolean{          if(speeder1.x + speeder1.distright < speeder2.x + speeder2.distleft) return false; //checking overlap on x axis         if(speeder1.x + speeder1.distleft > speeder2.x + speeder2.distright) return false;         if(speeder1.y + speeder1.distbot < speeder2.y + speeder2.disttop) return false; // checking overlap on y axis         if(speeder1.y + speeder1.disttop > speeder2.y + speeder2.distbot) return false;            return true;      } 

and here think problem is. have class called "spawner" , going handle objects being created , destroyed. here code trying splice objects array depending on whether destroyme bool set true. @ stage have confused shit out of myself appreciated!

    private function updatearray(e:event):void{          for(var i:int = _main.speederarray.length - 1; i>=0; i--){               var speeder:speeder = _main.speederarray[i];               if(speeder.destroyme){                 //trace("hello");                 removechild(speeder[i]); // take off stage                 _main.speederarray[i] = null;                 _main.speederarray.splice(i, 1); //remove array             }          }       } 

now, game runs 2 objects within same array collide, collision trace in output window straight after :

referenceerror: error #1069: property 1 not found on com.game.speeder , there no default value. @ com.game::spawner/updatearray()

no idea means :(

any appreciated guys!

the problem comes line removechild(speeder[i]); inside update function. speeder has no properties called 1 , 1 comes loop.

so, solve problem, should call

removechild(speeder);

speeder object @ position i of array. putting [] behind object same accessing property it. doing this:

removechild(speeder.1);


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -