San*_*yak 5 browser apache-flex actionscript-3 flex4
我在Flex 4中设计了一个测验应用程序.最后我想重新加载我的应用程序(即在浏览器中刷新页面).最后,我将在警报中显示分数.之后我想重新加载当前的应用程序.我怎样才能做到这一点?
要使刷新在单击警报后才发生:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark" xmlns:local="*"
>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.CloseEvent;
protected function refreshClicked(event:Event):void
{
Alert.show("Congratulations you won",
"Hooray!",
Alert.NO|Alert.YES, null, refreshFinish);
}
protected function refreshFinish(event:CloseEvent=null):void{
if(event == null){
event = new CloseEvent("refreshFinish");
event.detail = Alert.YES;
}
if(event.detail == Alert.YES){
navigateToURL(new URLRequest(FlexGlobals.topLevelApplication.url), "_self");
}
}
]]>
</fx:Script>
<s:Button label="Alert and Refresh" click="refreshClicked(event)" />
</s:Application>
Run Code Online (Sandbox Code Playgroud)
您可以通过从 Alert.show 的第三个参数或中删除“NO”选项来删除它。