def coupleAnimation(newBox: WordBox, animBox: WordBox, oldBox: WordBox): Animation = { val params = List( Parameter(animBox.x_= _, OutExpoEasing(animBox.x, oldBox.x + oldBox.width()))_ , Parameter(animBox.y_= _, InExpoEasing(animBox.y, oldBox.y))_) def onComplete() { wordBoxes = wordBoxes.filterNot(elem => elem == oldBox || elem == animBox) :+ newBox } new ObjectAnimation(params, 500, onComplete _) } AnimationSystem.animations(box1) += coupleAnimation(new WordBox(), box1, box2)

val params = List( Parameter(animBox.x_= _, OutExpoEasing(animBox.x, oldBox.x + oldBox.width()))_ , Parameter(animBox.y_= _, InExpoEasing(animBox.y, oldBox.y))_)

Object.setName(_) // grabs the mutator function of an object. Object.name_= _ // grabs the mutator function of a public variable.

val colorFunct = (color:Int) => object.parameter = color match { case 1 => "red" case 2 => "green" case 3 => "blue" } List(Parameter(colorFunct, LinearEval(1,3))_)

I've created a animation system for objects in Android using Scala. It behaves similarly to the object property animators for JQuery and TweenLite, but it uses no reflection. What this means is that animating objects is completely typesafe and checked at compile time by the compiler. It also works on android 2.3.3 (or lower, I haven't checked).In case you are unaware, reflection is a method by which a programming language like Java or Scala can examine and modify objects at runtime. It is generally needed for such things as object property animation because Java does not have anonymous functions or first class functions.An example of the syntax for this system is:The ObjectAnimation class takes a list of parameter objects, an animation duration, and a function of type () => Unit to run on completion (optional). The Parameter class takes a mutator function of type (T: Numeric) => Unit, and an easing object:An object's mutators can be passed around in Scala pretty easily once you get used to it.Then the easing object takes two values indicating the start and end values for the parameter. Then you end the parameter object with a _ because it is currently defined as a curried case class and the ObjectAnimation constructor handles the remainder of its construction.You can mix and match the easing functions for each of your objects parameters to create different and interesting animations. You can also stack a series of animations in the animation system and it will animate through each one in order.Parameter classes are also not limited to operating on numeric object parameters. Say I have an object with a parameter that takes "red", "green", and "blue". I can animate this parameter with the following code:If you want to look at the code for this, it's stored at https://www.gitorious.org/scala-animation-system/scala-animation-system/trees/master/animation