actionscript 3 - FLASH/AS3: Getting error on removing child. Parameter child must be non-null -


i'm trying remove movieclip says parameter child must non-null.

this script:

to make in stage, use:

function sayam (e:mouseevent):void{     nilai = 8;     if(nilai == temp) {     var ssayam:ayam_mc = new ayam_mc     stage.addchild(ssayam);     ssayam.x = 350.0;     ssayam.y = 330.0;     ssayam.width = 170.0;     ssayam.height = 170.0;     ssayam.instancename = "ayam";     arnam.push("ayam");     trace("arnam" +arnam);     trace(ssayam.instancename);     jual = jual + 4000;     temp = val[len-(len-len2)]     len2 = len2 + 1;     } else {             money = money - 4000;          }      } 

so, made 8 functions make 8 movieclips display in stage , push them array. array "arnam".

and remove code:

function deleteburger() {                 for(var i:number=arnam.length; >= 0; i--){                         removechild(arnam[i]);                         arnam.splice(i,1);                 }             } 

i've traced array , isn't null.

can me? thank :)

you shouldn't modify array in loop based on array's length, behaviour unpredictable.

for each(var child:sprite in arnam){     stage.removechild(child); } arnam = []; 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -