hi, Hope somone can assist as i am struggling a bit with this. the use case is that a user clicks a button on a widget, a second widget should then be opened with data from the first widget copied across to the newly opened widget. I can get the second widget open fine, but the data is not copied across unless i click the button a second time. Only on that second click is the sharedData routine in the second widget called. Relevant code snippets are as follows (flex viewer version = 2.3.1):1st widget (button click routine)
//call the range detail widget.
ViewerContainer.dispatchEvent(new AppEvent(AppEvent.WIDGET_RUN, ViewerContainer.getInstance().getWidgetId("Range Detail")));
//add the ArrayCollection data to the sharedData object on the BaseWidget class.
addSharedData("ArtyDetail", rangeDetailArray);
2nd widget
<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:esri="http://www.esri.com/2008/ags"
xmlns:viewer="com.esri.viewer.*"
xmlns:customValidators="Landmarc.customValidators.*"
initialize="myBaseWidgetInitHandler(event)"
widgetConfigLoaded="init()"
xmlns:supportClasses="com.esri.ags.skins.supportClasses.*">
protected function myBaseWidgetInitHandler(event:FlexEvent):void
{
ViewerContainer.addEventListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);
}
public function sharedDataUpdated(event:AppEvent):void
{
var data:Object = event.data;
switch (data.key)
{
//if arty detail there is a maximum of 2 items in the ArrayCollection. First is the grids, second (if present) is the direct fire firing point
case "ArtyDetail":
{
txtSta.text = data.collection[0].toString();
//if the artillery selection was a direct fire, then there will be a firing position in the second item in the collection
if (data.collection[1])
{
txtWeaponPosition.text = data.collection[1].toString();
}
break;
}