Hi all,
I'm struggling with a Flex 4.6 application that has to notify the main application when data is parsed. I think I should be using a custom event but I don't quite know where to start. At the moment I have three files in my project:
- Bevolkingspiramide.mxml, the main app
- DataProxy.as, a class to parse data from a loaded csv file
- PopulationSlice.as, a model/value object for formatting the data from the csv file

Bevolkingspiramide.mxml
PHP Code:
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               
xmlns:s="library://ns.adobe.com/flex/spark" 
               
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="700" minHeight="700"
               
creationComplete="init()" pageTitle="Bevolkingspiramide">
    <
fx:Script>
        <![
CDATA[
            
import mx.controls.Alert;
            
import mx.rpc.events.FaultEvent;
            
import mx.rpc.events.ResultEvent;
            
import mx.collections.ArrayCollection;
            
            
import proxy.DataProxy;
            
            private var 
myProxy:DataProxy = new DataProxy();
            [
Bindable] private var y1996:ArrayCollection = new ArrayCollection();
            
// load csv data
            
protected function init():void{
                
bevolkingService.send();
            }
            
            
            
            protected function 
httpService_faultHandler(event:FaultEvent):void
            
{
                
Alert.show(event.fault.faultString,"Something went wrong");                
            }
            
// send loaded data to parser
            
protected function bevolkingServiceResultHandler(event:ResultEvent):void
            
{
                
myProxy.handleData(bevolkingService.lastResult.toString());
            }
            
// make parsed data available in mxml
            
protected function getYear(year:int):ArrayCollection{
                
trace("getYear"); // function is called
                
trace(myProxy.populationMen.getItemAt(0).data96);
// this is empty, not yet there
                
for each(var value:Object in myProxy.populationMen){
                    
trace("popmen len: "+myProxy.populationMen);
                    
y1996.addItem(value.data96);
                }
                return 
y1996;
            }
        ]]>
    </
fx:Script>
    
    <
fx:Declarations>
        <!-- 
Place non-visual elements (e.g., servicesvalue objectshere -->
        <
s:HTTPService id="bevolkingService" 
                       
url="data/bevolking.csv"
                       
fault="httpService_faultHandler(event)" 
                       
result="bevolkingServiceResultHandler(event)"/>
    </
fx:Declarations>
    <
s:Form x="136" y="59">
// I can access this data
        
<s:FormItem label="{myProxy.populationMen.getItemAt(0).data96}">
            
            <
s:TextArea id="output" text="{bevolkingService.lastResult}"/>
        </
s:FormItem>
        <
s:FormItem label="">
// some dummy visualisation for testing, stays empty
            
<s:DropDownList dataProvider="{getYear(1996)}"></s:DropDownList>
        </
s:FormItem>
    </
s:Form>
</
s:Application
DataProxy.as:
PHP Code:
package proxy
{
    
import valueObjects.PopulationSlice;

    public class 
DataProxy
    
{
        
import mx.collections.ArrayCollection;
        
        private static const 
FIELD_DELIMITER:String ';';
        
        [
Bindable] public var populationMen:ArrayCollection = new ArrayCollection();
        
        public function 
DataProxy()
        {}
        
        public function 
handleData(data:String):void{
            var 
lines:Array = data.split("\n");
            
trace("len "+lines.length);
            for (var 
i:int=0lines.lengthi++) {
                var 
values:Array = lines[i].split(FIELD_DELIMITER);
                
// create population object
                
var people:PopulationSlice = new PopulationSlice();
                
people.data96 values[0];
                
people.data01 values[1];
                
people.data06 values[2];
                
populationMen.addItem(people);
            }
        }    
    }

PopulationSlice.as:
PHP Code:
package valueObjects
{
    [
Bindable]
    public class 
PopulationSlice
    
{
        public var 
data96:int;
        public var 
data01:int;
        public var 
data06:int;
        
        public function 
PopulationSlice()
        {
        }
    }

My question mainly is: what is the best way to make the data formatted the populationMen ArrayCollection available in the main app. Why isn't it visibly when I try to use it as a dataprovider in the app by calling it with this function: getYear(1996)?

Any help to get me on the way is greatly appreciated.