ActionScript2.0不使用startDrag的缓冲拖动

来源:互联网 发布:图论 教材 知乎 编辑:程序博客网 时间:2024/06/05 08:41
初学AS必须用2.0而且很多库不能用。移动的关键是mc._xmouse和mc._ymouse不能变


mc.onEnterFrame = function()
{
    if (isPress)
    {
        sx = _root._xmouse - mc._x;
        sy = _root._ymouse - mc._y;
        
        dx = sx - old_x ;
        dy = sy - old_y;
        
        mc._x = mc._x + dx * 0.3;
        mc._y = mc._y + dy * 0.3;
    }
    else
    {
        trace("else" + isPress);
        mc._x = mc._x;
        mc._y = mc._y;
    }
};

// var isPress = false;
mc.onPress = function()
{
    old_x = mc._xmouse;
    old_y = mc._ymouse;
    isPress = true;
};

mc.onRelease = function()
{
    isPress = false;
};

mc.onReleaseOutside = mc.onRelease;


0 0
原创粉丝点击