This is a translated page. The original can be found here: http://www.designscripting.com/2008/12/use-splice-to-delete-all-elements-in-an-array/
Home » ActionScript 2.0 , ActionScript 3.0 Etusivu » ActionScript 2.0 , ActionScript 3.0

Use Splice to delete all elements in an Array Käytä Splice poistaa kaikki tekijöitä Array

4 December 2008 04 joulukuu 2008 No Comment No Comment

In my project i was passing array to another class(passing by reference). Minun hanke olin ohimennen array toiseen luokkaan (ohimennen viittaus). And i was editing the items there in another class(Composition). Ja olin muokkaamalla kohteita siellä toiseen luokkaan (kokoonpano). I was in a situation to resset the array. Olin tilanteessa resset jono. Then i suddenly reinitialized the array(arr = new Array() or arr = []). Sitten yhtäkkiä reinitialized array (sov. = new Array () tai arr = []).
That will create some error in application. Tämä luo erehdyksen sovellus. Bcoz the reference will end there. Bcoz viittaus päättyy siellä.

So its advisable to delete items alone. Joten se kannattaa poistaa kohteita yksin. When passing the array references accross several Class. Kun kulkee joukko viittauksia useiden luokka.

 var Num_arr:Array = new Array(); var Num_arr: Array = new Array ();
Num_arr.push(1) Num_arr.push (1)
Num_arr.push(6) Num_arr.push (6)
Num_arr.push(2) Num_arr.push (2)
Num_arr.push(4) Num_arr.push (4)
Num_arr.push(9) Num_arr.push (9)
trace("--"+Num_arr+"--") jäljittää ("--"+ Num_arr +"--")
arr.splice(0,Num_arr.length) arr.splice (0, Num_arr.length)
trace("--"+Num_arr+"--") jäljittää ("--"+ Num_arr +"--") 

Happy coding Happy koodaus :)

VN:F [1.7.7_1013] VN: F [1.7.7_1013]
Rating: 0.0/ 10 (0 votes cast) Arvostelu: 0.0 / 10 (0 votes cast)
VN:F [1.7.7_1013] VN: F [1.7.7_1013]
Rating: 0 (from 0 votes) Arvostelu: 0 (0 ääntä)
Translate this post Käännä tämä viesti




Leave your response! Jätä vastaus!

Add your comment below, or trackback from your own site. Lisää kommentti alla, tai trackback polveutua sinun oma asema. You can also subscribe to these comments via RSS. Voit myös tilata näiden kommenttien kautta RSS.

Be nice. Ole hyvä. Keep it clean. Pidä se puhtaana. Stay on topic. Pysy aiheessa. No spam. Ei roskapostia.

You can use these tags: Voit käyttää näitä koodeja:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. Tämä on Gravatar-käytössä weblog. To get your own globally-recognized-avatar, please register at Gravatar . Saada oma maailmanlaajuisesti tunnustettu-hahmon, ilmoittaudu osoitteessa Gravatar .

CAPTCHA Image
Päivitä kuva