纺车?

时间:2012-10-01 17:23:39

标签: flash actionscript

我正在闪光灯中制作一个计数器。效果就像一台老虎机,有一列,包含两个带有数字的精灵(9,0,1,2,3,4,5,6,7,8)。我正在检查每个人的y位置,如果他们的y值小于某个y值,那么我将其移动到另一个y值以下,这样它就会连续变化。无论如何 - 我有一个每100毫秒运行一次的计时器,每次触发它都会更新一个值1.然后我想让数字滚动到那个位置,但这一切都变得很快,所以它一直来回跳跃=没有无缝循环。

有什么想法吗?

更新说明

该值不仅仅增加1,而是通过“tick”中的“inpValue”递增。我将有x个数量的代码,它们计数到一个递增的值(每次我的定时器触发时,例如每100ms),例如值可以是“1.03”,下次定时器触发时它可以是类似的“1.14”。我把这个数字分成三个“列”=代码,每个代码都有它的价值; ticker1:1 ticker2:1 ticker3:4

当ticker3接下来“0”-value = 10时,ticker2应该更新为“2”,依此类推。 问题是让数字滚动,如果数字是第一次“4”,下次它是“2”,它实际上应该滚动它之间的所有数字,依此类推,而不是跳回去行。

因此,如果我将价格“1.14”的代码停止,那应该是代码停止的价值。

编辑:代码

package gui {
import flash.events.Event;
import com.greensock.TweenMax;
import com.greensock.easing.Linear;
import com.greensock.TweenLite;

import flash.display.MovieClip;
import flash.display.Sprite;

public class Ticker extends Sprite {

    public var windowBg_mc:MovieClip;

    private var _stepValue:int = 0;

    public var row1:MovieClip;
    public var row2:MovieClip;
    private var _activeRow:MovieClip;

    public var stopBtn:MovieClip;

    public function Ticker() {
        init(0);
    }

    private function init(val:int):void{

        this.addEventListener(Event.ENTER_FRAME, updateConnection);

        _stepValue = val;

        TweenMax.to(row2, 0, {tint: 0xff0000});

        _activeRow = row1;

        var yMoveTarget_num:Number = -(Number(_stepValue) * 34);

        TweenLite.to(_activeRow, 5, {y: yMoveTarget_num, ease: Linear.easeNone});

        updateConnection(null);
    }

    private function updateConnection(e:Event):void{

        if(_activeRow.y <= -342){
            _activeRow.y = 340;
            if( _activeRow == row1 ){
                _activeRow = row2;
            }else{
                _activeRow = row1;
            }
        }

        if( _activeRow == row1 ){
            row2.y = row1.y + 340;
        }else{
            row1.y = row2.y + 340;
        }

    }

    public function tick(inpValue:int):void{

        if(_stepValue == inpValue) return;

        var oldValue : int = _stepValue;
        _stepValue = inpValue;

        if( _stepValue < oldValue ){
            //target must be change here
        }

        var yMoveTarget_num:Number = -(Number(_stepValue) * 34);
        TweenLite.to(_activeRow, .4, {y: yMoveTarget_num, ease: Linear.easeIn});
    }

}
}

“tick”是每100ms调用一次的方法。

0 个答案:

没有答案
相关问题