I have one main xml file wich contains 2 components. Component 1 is an upload component component 2 is a grid with a list. Both are in the same viewstate but i want component 2 to update when i uploaded a file in component 1.
So my question is: How can i send a trigger to component 2 from component 1 so it knows the grid has to be updated?
For communication between components, use events.
For instance inside component 1 dispatch a "complete" event whenever the upload is finished:
dispatchEvent(new Event(Event.COMPLETE));
Now listen for this event and tell component 2 what to do. Do something like this in your main class:
component1.addEventListener(Event.COMPLETE, handleUploadComplete);
private function handleUploadComplete(event:Event):void {
component2.updateGrid();
}
If you want MXML support for that, add the following metadata to component 1:
[Event(name="complete", type="flash.events.Event")]
You can then listen for the event like this and FlashBuilder will suggest the event handler:
<Component1 complete="handleUploadComplete()" />