我必须在闪存中检测用户是否关闭了浏览器或转到了另一个页面,并且闪存不再可用。我该如何实现?
最佳答案
ExternalInterfaceUtil.addExternalEventListener(“window.onunload”,handleLogout,“unloadFlex”);
package
{
import flash.external.ExternalInterface;
public class ExternalInterfaceUtil
{
public static function addExternalEventListener( qualifiedEventName:String, callback:Function,callBackAlias:String ):void
{
// 1. Expose the callback function via the callBackAlias
ExternalInterface.addCallback( callBackAlias, callback );
// 2. Build javascript to execute
var jsExecuteCallBack:String = "document.getElementsByName('"+ExternalInterface.objectID+"')[0]."+callBackAlias+"()";
var jsBindEvent:String = "function(){"+qualifiedEventName+"= function(){"+jsExecuteCallBack+"};}";
// 3. Execute the composed javascript to perform the binding of the external event to the specified callBack function
ExternalInterface.call( jsBindEvent );
}
}
}
我不记得我从哪里得到的,但是我已经使用了它,并且效果很好。当然,并非所有浏览器都可以合作,但是总比没有好……
关于actionscript-3 - 在浏览器关闭或更改页面(AS3)上通知Flash Player,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1119554/