Help with Splicing


i running issue multiple values being spliced, appears if removing every other value. not sure why happening, help/suggestions

 

my code

//mouseevent

 

function ansevent(e:mouseevent):void

{

//this gets called (# of answers) times

switch (e.type)

{

  case "click" :

   ansarray.push(e.currenttarget.text);

   if (! checkans(ansarray[0],correctans[0]))

   {

    trace("wrong");

   }

   else

   {

 

//problem area

    for(var i:int=0;i<solutions.length;i++){

     solutions.splice(i,1);

     }

//end problem area

 

    trace("match",match,"||","solutions",solutions);

    if (! solutions.length)

    {

     trace("end of game");

    }

   }

   break;

  case "mouseover" :

   break;

  case "mouseout" :

   break;

}

}

 

//where event added

function theanswer(e:event):void{

correctans.push(myxml.question.(@ id == questionid[0]).answer.(@ set =="right"). @ text);

for (var i:int=0; i<myxml.question.(@ id == questionid[0]).answer.length(); i++)

{

  ansbox = new textfield();

ansbox.addeventlistener(mouseevent.click,ansevent);

 

}

  }

 

//where theanswer called

function checkforsolution(e:timerevent):void{
getbool();
if(boolcheck == true){
   dispatchevent(new event("iniques"));
   dispatchevent(new event("inians"));
}
if(boolcheck == false){
//false actions 

}

}

 

 

 

output:

match card0,card1 || solutions card2,card3,card6,card7,card10,card11,card14,card15,card18,card19

splice working backwards thru array rather forwards.  when splice going forward, next item fills hole emptiied, escaping splice



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account