为AS2.0添砖加瓦-编写类扩展(4)

2016-01-29 14:06 1 1 收藏

为AS2.0添砖加瓦-编写类扩展(4),为AS2.0添砖加瓦-编写类扩展(4)

【 tulaoshi.com - Flash 】

mc的双击事件
1、建立CPoweredByXiaowu .as:
class CPoweredByXiaowu extends MovieClip
{
    var temp_mc:String;
    var firstTime:Number;
//----------------------------------------------------------------------------------------------------------------------------------------------
//这就是那个测试双击事件的函数,传递mc_name参数的作用是避免在同时点击两个不同的mc时出错
//----------------------------------------------------------------------------------------------------------------------------------------------
    function db_click (mc_name:String)
    {
        if (temp_mc == undefined || temp_mc == ""
        {
            temp_mc = mc_name;
            firstTime = getTimer ();
            return false;
        }
        if (temp_mc != mc_name)
        {
temp_mc = mc_name;
            firstTime = getTimer ();
            return false;
        }
        if (getTimer ()-firstTime=500)
        {
            temp_mc = "";
            return false;
        }
        temp_mc = "";
        return true;
    }
}

2、在flash中引用测试:
建立一个名为test的mc,将它Linkage,其class名当然为CPoweredByXiaowu咯。
然后加上这些代码:
_root.test.onPress = function()
{
    if(_root.test.db_click(String(this)))