Moved this general-purpose flash/mx class here, from the msoy project.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4190 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-06-13 21:03:25 +00:00
parent c90819ca69
commit 3e4ff3564d
2 changed files with 60 additions and 0 deletions
@@ -0,0 +1,31 @@
package com.threerings.mx.effects {
import mx.effects.EffectInstance;
import mx.effects.Effect;
public class FunctionEffect extends Effect
{
/** The function to call. */
public var func :Function;
/** The arguments to pass to the function. */
public var args :Array;
public function FunctionEffect (target :Object = null)
{
super(target);
instanceClass = FunctionEffectInstance;
}
// documentation inherited
override protected function initInstance (instance :EffectInstance) :void
{
super.initInstance(instance);
var fe :FunctionEffectInstance = (instance as FunctionEffectInstance);
fe.func = func;
fe.args = args;
}
}
}
@@ -0,0 +1,29 @@
package com.threerings.mx.effects {
import mx.effects.effectClasses.ActionEffectInstance;
public class FunctionEffectInstance extends ActionEffectInstance
{
public function FunctionEffectInstance (target :Object)
{
super(target);
}
/** The function to call. */
public var func :Function;
/** The args to pass. */
public var args :Array;
override public function play () :void
{
super.play();
// call the function!
func.apply(null, args);
// and we're done
finishRepeat();
}
}
}