Question
Collection with ActionScript 2.0
I try to use a collection under actionscript 2.0, but my code
seems not work...
This is my script for the .fla:
*************************************************
import mx.utils.*;
var mylib:MyLibrary;
myBook = new MyBooks();
myBook.Author = "roger";
myBook.Title = "flash";
mylib.myBooks.addItem(myBook);
trace ("Collection size: " + mylib.myBooks.getLength());
*****************************************************************
and this one for the .as':
**********************************************************************
*** MyLibrary ***
**********************************************************************
import mx.utils.*;
class MyLibrary extends mx.core.UIObject
{
[Collection(name="My Books",variable="myBooks",collectionClass="mx.utils.CollectionImpl", collectionItem="Books", identifier="Title")]
public var myBooks:Collection;
}
********************************************************************************************************
**********************************************
*** MyBooks.as ***
**********************************************
class MesLivres{
[Inspectable(type="String", defaultValue="Title")]
var titre:String;
[Inspectable(type="String", defaultValue="Author")]
var auteur:String;
}
**********************************************************
The response is invariably:
"Collection size: undefined"
Does nobody have an idea ????
Thanks.
This is my script for the .fla:
*************************************************
import mx.utils.*;
var mylib:MyLibrary;
myBook = new MyBooks();
myBook.Author = "roger";
myBook.Title = "flash";
mylib.myBooks.addItem(myBook);
trace ("Collection size: " + mylib.myBooks.getLength());
*****************************************************************
and this one for the .as':
**********************************************************************
*** MyLibrary ***
**********************************************************************
import mx.utils.*;
class MyLibrary extends mx.core.UIObject
{
[Collection(name="My Books",variable="myBooks",collectionClass="mx.utils.CollectionImpl", collectionItem="Books", identifier="Title")]
public var myBooks:Collection;
}
********************************************************************************************************
**********************************************
*** MyBooks.as ***
**********************************************
class MesLivres{
[Inspectable(type="String", defaultValue="Title")]
var titre:String;
[Inspectable(type="String", defaultValue="Author")]
var auteur:String;
}
**********************************************************
The response is invariably:
"Collection size: undefined"
Does nobody have an idea ????
Thanks.