something like that should do it:
public function Caddy() {
if ( getQualifiedClassName( super ) == "::Caddy" ) {
throw new ArgumentError( "Use get instance pl0x." );
}else{
_listproduct = new Array();
_views = new Array();
}
}
public function addView ( v : CaddyViewBase ) : void
{
if ( Boolean( view( v.name ) ) )
throw new Error ( "CaddyView with name'" + v.name + "'
has already been created." );
else if (!v.name )
throw new Error ( "Cannot create a CaddyView instance
without a name" );
_views.push( v );
}
public function view ( name : String ) : CaddyViewBase
{
var i : int = _views.length;
while ( i-- )
if ( _views[ i ].name == name ) return _views[ i ];
}
return null;
}
then I can retrieve by name and iterate through it
L
Hans Wichman a écrit :
Hi,
I'm guessing the dictionary object allows you to retrieve the size of
the keyset, might be of help.
greetz
JC
On Mon, Oct 27, 2008 at 2:58 PM, Paul Andrews <[EMAIL PROTECTED]> wrote:
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