我在一个应用程序中有两个sharedProperties,其中一个是另外一个batonProperty。如果我只想让其中一个同步,这很简单,我只需要向同步事件添加一个事件监听器。但是,如果我有两个,我仍然可以将事件侦听器附加到两个上,以检查它们何时同步,但是我如何等待它们同时同步呢?
任何我可以测试的代码示例都非常感谢。
我没有使用过sharedProperties,但是对于任何需要等待多个事件的情况,如果您不知道它们将以什么顺序发生,您可以在这个非常基本的设置行中使用一些东西:
var event1occurred:Boolean;
var event2occurred:Boolean;
function onEvent1(e:Event):void {
event1occurred = true;
checkIfAllEventsOccurred();
}
function onEvent2(e:Event):void {
event2occurred = true;
checkIfAllEventsOccurred();
}
function checkIfAllEventsOccurred():void {
if(event1occurred && event2occurred) {
// Do stuff here
}
}