Skip navigation
capitainequebec
Currently Being Moderated

Closing FLEX current application using AS

Jan 26, 2011 6:59 AM

I use the following code to close the current application using Action Script and JavaScript:

 

var urlString:String = "javascript:window.opener = self; self.close();";

var request:URLRequest = new URLRequest(urlString);

navigateToURL(request, "_self");

 

Then I got the message: SecurityError: Error #2121: Security sandbox violation: navigateToURL

 

Is there a way to solve the problem or should I use another way to close the current application from AS.

 

Regards,

 
Replies
  • Currently Being Moderated
    Jan 26, 2011 8:07 AM   in reply to capitainequebec

    Try using ExternalInterface to call JS method in the wrapper html.

     

    -Gaurav

    http://www.gauravj.com/blog

     
    |
    Mark as:
  • Currently Being Moderated
    Calculating status...
    Mar 8, 2011 8:18 AM   in reply to capitainequebec

    Have this in your Flex program:

     

    private function closeProgram():void
    {
          ExternalInterface.call("window.close");
    }

     

    call it when you need it.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2011 8:38 AM   in reply to capitainequebec

    add

    import flash.external.*;

    to your program.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2011 8:49 AM   in reply to capitainequebec

    How are you actually running your program?

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2011 9:06 AM   in reply to capitainequebec

    Not sure if it's working when you are running it from the Builder. Also did you mention it was for AIR? I use my code for a compiled Flex app running in Browser.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2011 10:35 AM   in reply to capitainequebec

    The code I am providing is used only for a flex web application. I do not use it, nor recommend it for an AIR application.

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 8, 2011 12:12 PM   in reply to capitainequebec

    See NativeApplication.exit()

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points