Hello :)

See the documentation of the Array class and the splice method :

splice(startIndex:Number <00002026.html#419506>,
[deleteCount:Number<00002026.html#419506>],
[value:Object <00002035.html#421878>])


The null value don't remove an item in the Array instances :) clean only the
value in the case :)

If you use a property in an object use 'undefined' or 'delete' :

var o = {} ;
o.prop1 = 1 ;
o.prop2 = 2 ;
trace(o) ;

for (var prop in o )
{
      trace( prop  + " : " + o[prop] ) ;
}

trace("--- remove prop1") ;

trace( "remove prop1 : " + delete o.prop1 ) ;

for (var prop in o )
{
      trace( prop  + " : " + o[prop] ) ;
}

... If you want keep the property but this property not must be enumerable
in the for..in loop, use ASSetPropFlags :

var o = {} ;
o.prop1 = 1 ;
o.prop2 = 2 ;
trace(o) ;

ASSetPropFlags(o, ["prop1"] , 1 ) ;

// with the for..in
for (var prop in o )
{
      trace( prop  + " : " + o[prop] ) ;
}

// but the property exist :
trace(o.prop1 ) ;


EKA+ :)

2007/10/19, Andrew Sinning <[EMAIL PROTECTED]>:
>
> A question in my sent box from when the list went down:
>
> I like to use the Object class as an index, but there doesn't appear to
> be a way to completely remove a property from an object.  I can set the
> value to null, but I'd really like to be able to remove the property
> completely.  Why? Because if I want to do a reverse lookup, then I have
> to iterate through all of the properties, but having to iterate through
> the nulled values seems inefficient.
>
> I can do this with another class, something that includes an Array to
> keep track of current properties and an Object for the index, but I'm
> wondering if I'm overlooking something.  Often I find that I am.
>
> Speaking of Arrays, it's a bit frustrating that there's no easy way to
> remove an item from an array either.  Currently I use:
>
>    iterate through the array to find the index of the needle
>    splice the Array at the index
>
> Is there a faster way to remove an item from an array?
>
>
> Thanks!
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to