AS3 Navigatetourl causes externalinterface execution failure _flash AS3

Source: Internet
Author: User
Tags cdata
We'll look at the following code:
Copy Code code as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml" layout= "Absolute" >
<mx:Script>
<!--[cdata[
Import Flash.external.ExternalInterface;
Private Function init1 (): void
{
var url:string = "Javascript:alert (' executive Navigatetourl ');";
var request:urlrequest = new URLRequest (URL);
Navigatetourl (Request, "_self");
}
Private Function Init2 (): void
{
Externalinterface.call ("function function1 () {alert (' Execute Externalinterface ');}");
}
Private Function Clickfun (): void
{
Externalinterface.call ("function function2 () {window.document.title = ' changed title ';}");
}
]]-->
</mx:Script>
<mx:button x= "y=" label= "1" click= "init1 ()"/>
x= "544" y= "<mx:button" label= "2" click= "Init2 ()"/>
<mx:button x= "404" y= "315" label= "change title" click= "Clickfun ()"/>
</mx:Application>
<?xml version= "1.0" encoding= "Utf-8"?>
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml" layout= "Absolute" >

<mx:Script>
<!--[cdata[
Import Flash.external.ExternalInterface;

Private Function init1 (): void
{
var url:string = "Javascript:alert (' executive Navigatetourl ');";
var request:urlrequest = new URLRequest (URL);
Navigatetourl (Request, "_self");
}
Private Function Init2 (): void
{
Externalinterface.call ("function function1 () {alert (' Execute Externalinterface ');}");
}

Private Function Clickfun (): void
{
Externalinterface.call ("function function2 () {window.document.title = ' changed title ';}");
}

]]-->
</mx:Script>
<mx:button x= "y=" label= "1" click= "init1 ()"/>
x= "544" y= "<mx:button" label= "2" click= "Init2 ()"/>
<mx:button x= "404" y= "315" label= "change title" click= "Clickfun ()"/>

</mx:Application>

Functions Init1 and Init2 are all through JavaScript pop-up balloons, Clickfun () to modify the page title.
3 functions performed individually are successful, but when
1. Executing the INIT1 function before calling the Clickfun function will find Clickfun execution failed.
2. Executing the INIT2 function before calling the Clickfun function will find Clickfun execution successful.
Could it be that navigatetourl will cause externalinterface execution to fail?? Please know the reason of the friend under the guidance.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.