OK, I'm not sure if I follow, but..

You basically want named views onto a set of data, each view uses a separate object to hold the data for its own particular view.

You could use an array of objects to store the view data and each view object could contain a view name.

I'm not really sure how the view name is being used - if it's a finite number of views I'd probably use a constant for the view name as an index into the array:

var FIRST_VIEW:uint = 0;
var SECOND_VIEW:uint = 1;

etc.

so then we refer to view[FIRST_VIEW].

If it's a true associative array you're after you might need a dictionary.

A lot of people try and write AS3 code using AS1/AS2 habits, so that's why I asked.

Paul

----- Original Message ----- From: "laurent" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Monday, October 27, 2008 2:25 PM
Subject: Re: [Flashcoders] AS3 associativ array length=0



I have a static Caddy Class that needs defferent views to show its content. I think I really need to store them with a name, so I could make a viewsNum to store how many views I got.

The thing is then I update all the views and need to iterate through the whole views array/object. For that I should have an array of views with a numeric index and so, no name storing them. Dilema

or I make two arrays one for the name, and another for the objects, with same index.

or store the name in the CaddyView class and when calling a view by it's name just look in views array with the one that have the good name.

I think all the case are here, which one do you want Paul ? :) thx

L

Paul Andrews a écrit :
If you want an associative array like that use Object, not Array. The length of an array is the number of elements in the array, so it's 0. obj["name"] is referring to an attribute of an object not an element of an Array..

Do you really have to store values like that?

Paul


----- Original Message ----- From: "laurent" <[EMAIL PROTECTED]>
To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com>
Sent: Monday, October 27, 2008 1:35 PM
Subject: [Flashcoders] AS3 associativ array length=0


Hi,

I use an array to store object with their name like that:
views[ "viewName" ] = Object

then views.length return 0 ...

It's normal behaviour ?? length work only on numerical indexes ?

L

_______________________________________________
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



_______________________________________________
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