Flash播放器在浏览器关闭或改变页面通知(AS3) [英] Flash player notified on browser close or change page (as3)

查看:375
本文介绍了Flash播放器在浏览器关闭或改变页面通知(AS3)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检测我的闪光,如果用户关闭浏览器或转到另一个页面,闪光灯无法再访问。我如何做到这一点?

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

这篇关于Flash播放器在浏览器关闭或改变页面通知(AS3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆