From 3e4ff3564d54c613cca3c4dadab1c56ab0d24aba Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Tue, 13 Jun 2006 21:03:25 +0000 Subject: [PATCH] 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 --- .../threerings/mx/effects/FunctionEffect.as | 31 +++++++++++++++++++ .../mx/effects/FunctionEffectInstance.as | 29 +++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/as/com/threerings/mx/effects/FunctionEffect.as create mode 100644 src/as/com/threerings/mx/effects/FunctionEffectInstance.as diff --git a/src/as/com/threerings/mx/effects/FunctionEffect.as b/src/as/com/threerings/mx/effects/FunctionEffect.as new file mode 100644 index 000000000..ab1dac74e --- /dev/null +++ b/src/as/com/threerings/mx/effects/FunctionEffect.as @@ -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; + } +} +} diff --git a/src/as/com/threerings/mx/effects/FunctionEffectInstance.as b/src/as/com/threerings/mx/effects/FunctionEffectInstance.as new file mode 100644 index 000000000..afbd9df55 --- /dev/null +++ b/src/as/com/threerings/mx/effects/FunctionEffectInstance.as @@ -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(); + } +} +}