MVC-Architektur .... gut in einfachen Fällen nur das Modell Teil:
package
{
[Bindable]
public final class ShellModelSingleton
{
public var selectedStatus:ArrayCollection;
////////////////////////////////////////////
// CONSTRUCTOR
// ****DO NOT MODIFY BELOW THIS LINE*******
///////////////////////////////////////////
public function ShellModelSingleton(){}
/****************************************************************
* Singleton logic - this makes sure only 1 instance is created
* Note: you are able to hack this since the constructor doesn't limit
* a single instance
* so make sure the getInstance function is used instead of new
* ShellModelSingleton()
*****************************************************************/
public static function getInstance():ShellModelSingleton {
if(_instance == null) {
_instance = new ShellModelSingleton();
}
return _instance;
}
protected static var _instance:ShellModelSingleton;
}
}
Dann können Sie die Singleton von jeder Komponente wie diese aktualisieren und verwenden:
[Bindable] private var model:ShellModelSingleton =
ShellModelSingleton.getInstance();
Komponente 1
<mx:DataGrid id="myDG" dataProvider="{model.selectedStatus}" />
Komponente 2
<mx:List id="myList" dataProvider="{model.selectedStatus}"
labelField="label" />
Anschließend werden alle Änderungen, die Sie an der ausgewähltenStatus-Auflistung vornehmen, in beiden Komponenten aktualisiert.
Angenommen, sie haben nicht alle eine gemeinsame Mutterkomponente? –
Ich meinte Elternkomponente wie in Ihrer Anwendungskomponente. Dort deklarierte Variablen haben im Wesentlichen einen globalen Geltungsbereich. – CookieOfFortune