mardi 12 mai 2009

Thou shall not touch Lists at the Beginning

As strange as it looks like, if you try to access to the dataProvider of a List created in flash from the constructor of a class associated to a movieclip that owns the list, you'll get a bug. In fact, it seems that the dataProvider of the list object is initialized after the constructor of the parent movieclip is executed, meaning that whatever you do with the list or its dataProvider in the constructor will not be shown. Very simple example:
  1. in flash 9, create a new movieclip and add to it a List component.
  2. create a classe for the movieclip.
  3. add in the class a constructor with the following content: myList.dataProvider.addItem({label:"test",data:0});
  4. run it and expect to see a list with a line "test". But because of some kind of bug, nothing appears in the list.
However, if you do the addItem from a button click event, it works perfectly fine.

Aucun commentaire:

Enregistrer un commentaire