no that's correct but id should be declared outside of your loop - as3 will
actually give you a duplicate variable error for putting it inside the loop.
you can also refer to your iterator (i) after the loop is done
i'd rewrite your function like this
var arObj:Array = [{},{}]
function test():void
{
var id:String;
for each(var i:Object in arObj)
{
trace("1" ,id);
id = "test" + Number(Math.random()).toString();
trace("2" ,id);
}
trace(i);
}
best
a
On 4 August 2010 10:45, Jiri <[email protected]> wrote:
> I have the following case:
>
> var l:Array = [{},{}]
> function test():void{
> for each(var i:Object in l){
> var id:String;// = null;
> trace("1" ,id);
> id = "test" + Math.random().toString();
> trace("2" ,id);
> }
> }
>
> I seems that 'id' is not resetted to null on every iteration as I would
> expect. I have to explicitly set the id to null myself! Does some know why
> this is, or are my expectations just wrong.
>
>
> Jiri
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders