Skip to content

Instantly share code, notes, and snippets.

@triplefox
Created December 20, 2014 08:49
Show Gist options
  • Save triplefox/fdf9614bf3c8940c3d3c to your computer and use it in GitHub Desktop.
Save triplefox/fdf9614bf3c8940c3d3c to your computer and use it in GitHub Desktop.
demo for Slactuate
import flash.Lib;
import flash.display.Shape;
class Main
{
public static var sp : Shape;
public static var slac : Slactuate;
static function main()
{
sp = new Shape();
Lib.current.addChild(sp);
sp.graphics.beginFill(0xFF880088, 1.);
sp.graphics.drawCircle(0., 0., 64.);
slac = new Slactuate();
Lib.current.addEventListener(flash.events.Event.ENTER_FRAME, onFrame);
}
static function onFrame(event)
{
slac.u(Lib.getTimer());
slac.c();
if (slac.td.length < 1)
{
//var goalx = 0.; if (sp.x == 0.) goalx = 300.;
var goalx = Math.random()*Lib.current.stage.stageWidth;
var goaly = Math.random()*Lib.current.stage.stageHeight;
var t = Lib.getTimer();
slac.p(sp, "x", Slactuate.lutlinear([0.,0.5,1.1,1.3,1.5,0.9,1.0]), t, t + 1000., sp.x, goalx, 0);
slac.p(sp, "y", Slactuate.lutlinear([0.,0.5,1.1,1.3,1.5,0.9,1.0]), t, t + 1000., sp.y, goaly, 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment