# ArrayCollection data disappears when switching View?

**URL:** https://forum.kirupa.com/t/arraycollection-data-disappears-when-switching-view/319510
**Category:** Uncategorized
**Created:** [February 23, 2011, 3:52am UTC](https://forum.kirupa.com/t/arraycollection-data-disappears-when-switching-view/319510 "2011-02-23T03:52:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Fran711](https://avatars.discourse-cdn.com/v4/letter/f/6f9a4e/32.png) [@Fran711](https://forum.kirupa.com/u/Fran711)
#### Post date: [February 23, 2011, 3:52am UTC](https://forum.kirupa.com/t/arraycollection-data-disappears-when-switching-view/319510/1 "2011-02-23T03:52:11Z")

</div>

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:

```auto

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:

```auto

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>

```
