我要检测我的闪光,如果用户关闭浏览器或转到另一个页面,闪光灯无法再访问。我如何做到这一点?
I have to detect in my flash if the user closes his browser or goes to another page and the flash is not accessible anymore. How do i achieve that ?
ExternalInterfaceUtil.addExternalEventListener(window.onunload,handleLogout,unloadFlex);
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 );
}
}
}
我不记得在那里我从得到这个,但我用它和它的作品pretty的好。当然,并不是所有的浏览器都将进行合作,但总比没有好......
I don't remember where I got this from, but I've used it and it works pretty well. Of course not all browsers are going to cooperate, but it is better than nothing...