forked from: forked from: forked from: Tweenerの挙動?

by beinteractive forked from forked from: forked from: Tweenerの挙動? (diff: 21)
丸められない別の変数に一時的に格納しておくが一番楽かと。
あーサンプルが悪かったですね。
今度はクリックするたびにrotationを10づつ増やしてみる。180を超えると1回転する
自己解決、無知晒し上等、Tweenerも糞も関係ない。rotationの値が-180~180だったのね。
結局 
なんかライブラリ上で上手いこと処理してくれたら嬉しいのにな。
しかくクリックでTweener動きます
rotation181以上で同じ値でTweenさせると、なぜぐるっと一回転するのか?
回らないのを想像してたんだが・・・いまさら?
なんかいい回避方法ないですか?って概出?
おとなしく違うライブラリ使えってことですね。
♥0 | Line 42 | Modified 2010-07-21 15:29:54 | MIT License
play

ActionScript3 source code

/**
 * Copyright beinteractive ( http://wonderfl.net/user/beinteractive )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/dZny
 */

// 丸められない別の変数に一時的に格納しておくが一番楽かと。
// forked from minon's forked from: forked from: Tweenerの挙動?
//あーサンプルが悪かったですね。
//今度はクリックするたびにrotationを10づつ増やしてみる。180を超えると1回転する
//自己解決、無知晒し上等、Tweenerも糞も関係ない。rotationの値が-180~180だったのね。
// 結局 
//なんかライブラリ上で上手いこと処理してくれたら嬉しいのにな。
// forked from Murai's forked from: Tweenerの挙動?
// forked from minon's Tweenerの挙動?
//しかくクリックでTweener動きます
//rotation181以上で同じ値でTweenさせると、なぜぐるっと一回転するのか?
//回らないのを想像してたんだが・・・いまさら?
//なんかいい回避方法ないですか?って概出?
//おとなしく違うライブラリ使えってことですね。

package {
    
    import caurina.transitions.Tweener;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.display.Sprite;
    
    public class FlashTest extends Sprite {
        
        private var _box:Sprite;
        private var _boxRotation:Number;
        private var _txt:TextField;
        private var next:Number;
        
        public function FlashTest() {
            // write as3 code here..
            
            _box = new Sprite();
            _box.graphics.beginFill( 0xFF0000, 1 );
            _box.graphics.drawRect( -50, -50, 100, 100 );
            _box.graphics.endFill();
            _box.x = _box.y = 200;
            this.addChild( _box );
            
            _boxRotation = 0.0;
            
            _txt = new TextField();
            _txt.border = true;
            _txt.text = "100";
            _txt.type = TextFieldType.INPUT;
            this.addChild( _txt );
            next = _box.rotation;
            
            var self:FlashTest = this;
            
            _box.addEventListener( MouseEvent.CLICK, function():void {
               //Tweener.addTween( _box, { rotation:(Number(_txt.text)%180+180)%180, time:0.6, transition:"easeOutQuad" } );
               //ってことかとおもったけど、こういうこと?
               //if(next == Number(_txt.text))return;
               next = Number(_txt.text) + 10;
               _txt.text = next + "";
               Tweener.addTween(self, { boxRotation:Number(next), time:0.6, transition:"easeOutQuad" } );
            } );
        }
        
        public function get boxRotation():Number
        {
            return _boxRotation;
        }
        
        public function set boxRotation(value:Number):void
        {
            _box.rotation = _boxRotation = value;
        }


    }
}