当前位置: 首页 > 图文教程 > Flash动画 > Flash动画制作 > 为AS2.0添砖加瓦-编写类扩展(4)

Flash动画制作
Flash的事件机制:从AsBroadcaster到EventDispatcher
Flash脚本的执行顺序
完全掌握AS中点(.)语法的应用
抗日Flash集之:万里长城永不倒
抗日Flash集之:地道战
抗日Flash集之:抗日新闻
抗日Flash集之:三一八惨案
抗日Flash集之:五四运动
抗日Flash集之:抗日一隅
抗日Flash集之:血染的风采
抗日Flash集之:淞沪抗战
抗日Flash集之:终日到底
抗日Flash集之:东京功略战[游戏]
抗日Flash集之:大中华·1937
抗日Flash集之:长征
抗日Flash集之:抗日宣言
抗日Flash集之:血战钓鱼岛
用Flash MX制作MOV短片
用flash打开本地文件夹
Flash打造迷你特色音乐播放器

Flash动画制作 中的 为AS2.0添砖加瓦-编写类扩展(4)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-22   浏览: 56 ::
收藏到网摘: n/a

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