How to update the application in Flex?

I developed a quiz application in Flex 4. In the end, I want to restart my application (this is a page refresh in a browser). At the end I will show the score in the alert. After that, I want to restart the current application. How can i do this?

+5
source share
3 answers

To revive the update until your warning is clicked:

<?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>

You can remove the "NO" option by removing it from the third or third parameter of Alert.show.

+3
source

just go back to your website :)

navigateToURL(new URLRequest("linktoyourwebsite"));

to get the current url of the page, you can use the following code:

import flash.external.ExternalInterface;

var pageURL:String = ExternalInterface.call('window.location.href.toString');

:

var pageURL:String = ExternalInterface.call('window.location.href.toString');
navigateToURL(new URLRequest(pageURL));
+3

another answer. we must call the function in AS3

ExternalInterface.call("reload"); 

in the html file in javascript we have to define the reload function

 function reload()
    {
    window.location.reload(true);
    }
0
source

All Articles