打印

[特效] 怎么实现拖曳的缓动效果?带源文件求组~~~~~

首先请看一下未能实现缓动前的效果:
http://www.hj63.com/wxl/dragImg.swf

我想实现的是拖曳滚动条的时候,能让上面的图片缓动的移过来

请大大们帮忙看一下. 我的源文件在这里:
http://www.hj63.com/wxl/dragImg.fla
复制内容到剪贴板
代码:
var IMAGE_WIDTH = 100;
var sccrol_width = scrollBG_mc._width*IMAGE_WIDTH/images_mc._width;
var xishu:Number = IMAGE_WIDTH/sccrol_width;
var img_x = images_mc._x;
tpscroll_mc._width = sccrol_width;
tpscroll_mc.onPress = function() {
    var yx = images_mc._x;
    this.startDrag(false, scrollBG_mc._x, scrollBG_mc._y-4, scrollBG_mc._width+scrollBG_mc._x-sccrol_width, scrollBG_mc._y-4);
    this.onEnterFrame = function() {
        var _posX:Number = -(tpscroll_mc._x-scrollBG_mc._x)*xishu+img_x;
        images_mc._x += (_posX-images_mc._x)*.2;
        Math.abs(_posX-images_mc._x)<.2 && delete this.onEnterFrame;
    };
};
tpscroll_mc.onRelease = function() {
    this.stopDrag();
    //delete this.onEnterFrame;
};
tpscroll_mc.onReleaseOutside = tpscroll_mc.onRelease;
刚刚才把闪吧的帖子回了。
真是太感谢您了 .
ps: 我也刚刚在闪吧那感谢了您, 哈哈`~
flash023 版主(每次看到都是flash023最先为别人热心解惑,真的很佩服)
的方法只是实现普通的缓动,其实还有其它的缓动,建议楼主看看tween和easing类,那样能够制作更加丰富的缓动!
可以参考一下下面的一个教程,写的很不错:
http://www.webstudio.com.cn/tutorial/show.php?id=16
希望

TOP

还在为头像烦恼?还在为不能关注好友动态烦忧?快来蓝色理想家园吧!
恩,我现在也喜欢用tween做缓动.偶尔做不出来的东西去网上查到时候,基本代码都是用onenterframe做的,所以来问一下onenterframe缓动的问题
谢谢你们的解答

TOP

tween和easing类做出的缓动很生硬,就是不自然!

反正我是有这种感觉.

TOP