flash on 2014-12-1

by tepe
♥0 | Line 30 | Modified 2014-12-01 22:10:09 | MIT License
play

ActionScript3 source code

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

package {
    import flash.display.*;
    import flash.events.*;
    import flash.text.*;
    import com.bit101.charts.LineChart;
        public class FlashTest extends Sprite {
        //画面構成
        public var chart:LineChart;//チャート画面
        private var tf:TextField = new TextField();
        public function FlashTest() {
            // write as3 code here..
            addChild(tf);
            tf.text = "test";
            tf.x = 250;
            chart = new LineChart(this, 10,5);
            chart.data = [];
            addEventListener(Event.EXIT_FRAME,onFrame);
            
        }
        private var cnt:int=0;
        private function onFrame(e:Event):void{
            cnt++;
            //cnt %= 5;
            //if(cnt%5 != 0)return;
            var n:Number = sigmoid(cnt);
            tf.text = n.toString()+"\n"+cnt.toString();
            if(n==1)cnt = -50*Math.random();
            chart.data.push(n);
            chart.draw();
        }

        
        public function sigmoid(n:Number):Number{
            return 1 / (1 + 1 / Math.exp(n));
        }
    }
}