Created
December 8, 2011 12:37
-
-
Save DavidArno/1446872 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flash.display.MovieClip | |
import flash.display.Sprite | |
import haxe.Timer | |
import flash.Lib | |
class MathSinbyexample | |
@RED: Int = 0xFF0000 | |
_stage:MovieClip | |
_view_mc:Sprite | |
_wide:Int | |
_step:Int | |
_amplitude:Int | |
_timeStep:Int | |
_timer:Timer | |
_x:Int | |
_y:Float | |
_dAngle:Int | |
_radians:Float | |
_angleChange:Float | |
new _wide, _step, _amplitude, _timeStep, _dAngle -> | |
_stage = Lib.current | |
_radians = 0 | |
_angleChange = _dAngle * Math.PI/360 | |
_init | |
_init -> | |
_createView | |
_view_mc.graphics.lineStyle 0, RED, 1 | |
_timer = new Timer _timeStep | |
.run = _drawSine | |
_createView -> | |
_stage.addChild _view_mc = new Sprite | |
.x = 10 | |
.y = 20 | |
_drawSine -> | |
_timer.stop if (_x += _step) > _wide | |
_radians += _angleChange | |
_y = _amplitude * Math.sin _radians | |
_view_mc.graphics.lineTo _x, _y | |
@main -> | |
new MathSinbyexample | |
.wide = 760 | |
.step = 3 | |
.amplitude = 200 | |
.timeStep = 30 | |
.dAngle = 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment