Hi all,
I’ve been struggling for hours on what should be this easy task, but now I want to throw my monitor out the window. I’m trying to populate a List with an ArrayCollection.
In the first View, when I hit the ‘save’ button I’ve created, it seems like the data is successfully added to the ArrayCollection. But when I open the View where the ArrayCollection is supposed to be displayed, nothing is there.
Any help would be greatly appreciated. =)
part of .mxml file where data is added and saved:
protected function button2_clickHandler(event:MouseEvent):void // save button
{
var myc:MyCards = new MyCards();
myc.add();
myc.save();
tcard.text = "Done!";
}
Here is my second .mxml file with the actual add() and save() as well as containing the list:
public function add():void
{
var nctitle:NewCard = new NewCard();
card.fTitle = nctitle.tcard.text;
cards.addItem(fTitle);
testItem = "hello";
cards.addItem(testItem);
trace(cards.list); // add data that has been added shows up here
}
public function save():void
{
file = File.documentsDirectory.resolvePath(directory + "/" + fileName);
fileStream = new FileStream();
fileStream.open(file, FileMode.WRITE);
fileStream.writeObject(cards);
fileStream.close();
}
public function myCardsList_creationCompleteHandler(event:FlexEvent):void
{
trace(cards.list); // no data at all shows up here
}
]]>
</fx:Script>
<s:List id="myCardsList" x="10" y="10" left="0" right="0" top="0" bottom="0" width="1004"
height="500" dataProvider="{cards}" enabled="true" >
</s:List>