Thank you Robert for the clarification, unfortunately I still cannot get it worked.
I still have something to confirm:
(1) I the widget B init() function, should I use:
AppEvent.addListener(AppEvent.DATA_PUBLISH, sharedDataUpdated);
AppEvent.addListener(AppEvent.DATA_NEW_PUBLISHED, sharedDataUpdated2);
OR use:
AppEvent.addListener(AppEvent.DATA_NEW_PUBLISHED, sharedDataUpdated2);
AppEvent.addListener(AppEvent.DATA_SENT, sharedDataUpdated2);
(2) The 2 methods:
private function sharedDataUpdated(event:AppEvent):void
{
var data:Object = event.data;
if (data.key == "QueryState")
{
var theObj:Object = data.collection[0];
getSqlQuery = theObj.sql;
}
}
private function sharedDataUpdated2(event:AppEvent):void // DATA_NEW_PUBLISHED
{
var dataTable:Hashtable = event.data.data as Hashtable;
if (dataTable.containsKey("QueryState"))
{
var recAC:ArrayCollection = dataTable.find("QueryState") as ArrayCollection;
var theObj:Object = recAC[0];
getSqlQuery = theObj.sql;
}
}
The fact is if I use
var data:Object = event.data.data;
I can get the shared data.
But if I use
var dataTable:Hashtable = event.data.data as Hashtable;
I can't get the shared data, in this case cause error.
So sorry for the trouble caused, thanks a lot!
It is so strange that I can add code in the edit view but it is messy after I publish it (there is no tab before the code). Seems I am so stupid.