AQReturnValue
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Author: | Arthur Clemens |
| Classpath: | org.asapframework.util.actionqueue.AQReturnValue |
| File last modified: | Thursday, 12 October 2006, 11:19:40 |
ActionQueue method that returns a calculated (percentage) value of an animation in time.
Use this method to keep track of a (animated/calculated) value without directly manipulating a movieclip - to store the value or use it to update multiple other clips or values.
Use this method to keep track of a (animated/calculated) value without directly manipulating a movieclip - to store the value or use it to update multiple other clips or values.
Summary
Class methods
- returnValue (inPerformingObject:Object, inPerformingMethod:Object, inDuration:Number, inStartValue:Number, inEndValue:Number, inEffect:Function) : ActionQueuePerformData
- Calls a callback method with a calculated (percentage) value of an animation.
Class methods
returnValue
static function returnValue (
inPerformingObject:Object,
inPerformingMethod:Object,
inDuration:Number,
inStartValue:Number,
inEndValue:Number,
inEffect:Function) : ActionQueuePerformData
Calls a callback method with a calculated (percentage) value of an animation. You need to pass a callback object and method to pass the animated value to. The value that is passed is the percentage value calculated over time, between inStartValue and inEndValue.
Parameters:
inPerformingObject:
callback object
inPerformingMethod:
callback (object's) method (name or function reference): method to pass the calculated value
inDuration :
length of the animation in seconds; 0 is used for perpetual animations - use -1 for instant change
inStartValue :
(optional) start value: the value that is returned when no time has passed; this may be any number, including numbers larger than the end value, or negative numbers; default 0 is assumed
inEndValue :
(optional) end value: the value that is returned when _duration_ time has passed; this may be any number, including numbers smaller than the start value, or negative numbers; default 1000 is assumed
inEffect :
(optional) An effect function, for instance one of the mx.transitions.easing methods. Arguments to pass the effect function may be appended as a comma-separated list.
Returns:
- True (this method has an onEnterFrame) (to flag optimization for ActionQueue).
Example:
- This example calls the method "setPercentage" during 0.5 seconds, and sets its argument value during this time from 0 to 100:
queue.addAction( AQReturnValue.returnValue, this, "setPercentage", 0.5, 0, 100 ); // ... public function setPercentage (inPercentage:Number) : Void { updateVisualStatus(inPercentage); if (inPercentage == 100) { // stop } }
To create simultaneous movieclip effects, let the called method set multiple variables or methods. For example:queue.addAction( AQReturnValue.returnValue, this, "setScale", 0.2, 0, 1 ); // ... private function setScale (inPercentage:Number) : Void { label_mc.setLabelBackgroundBlend( LABEL_BG_MIN_ALPHA + (LABEL_BG_MAX_ALPHA - LABEL_BG_MIN_ALPHA) * inPercentage ); _xscale = _yscale = 100 + ((MAX_SCALE - 100) * inPercentage); if (mColTransformDuringAnimation != undefined) { ColorUtils.setMixTransform( image_mc, mColTransformDuringAnimation, mColTransformNormal, inPercentage); } }
ActionQueue has the utility function ActionQueue.relativeValue to make the calculation of the changing value a bit easier. For example:public function moveToActualPosition () : Void { mStartIntroPosition = new Point(_x, _y); mStartIntroScale = _xscale; var duration:Number = 2.0; var queue:ActionQueue = new ActionQueue(); queue.addAction( AQReturnValue.returnValue, this, "performMoveToActualPosition", duration, 0, 1); queue.run(); } private function performMoveToActualPosition (inPercentage:Number) : Void { _x = ActionQueue.relativeValue( mStartIntroPosition.x, mPosition.x, inPercentage ); _y = ActionQueue.relativeValue( mStartIntroPosition.y, mPosition.y, inPercentage ); _xscale = _yscale = ActionQueue.relativeValue( mStartIntroScale, mScale, inPercentage ); }