Home » ActionScript 2.0, ActionScript 3.0

Use Splice to delete all elements in an Array

4 December 2008 No Comment

In my project i was passing array to another class(passing by reference). And i was editing the items there in another class(Composition). I was in a situation to resset the array. Then i suddenly reinitialized the array(arr = new Array() or arr = []).
That will create some error in application. Bcoz the reference will end there.

So its advisable to delete items alone. When passing the array references accross several Class.

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

Happy coding :)

VN:F [1.7.7_1013]
Rating: 0.0/10 (0 votes cast)
VN:F [1.7.7_1013]
Rating: 0 (from 0 votes)
Translate this post
        
        
        
        
  

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<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. To get your own globally-recognized-avatar, please register at Gravatar.