[Tweener] Use var to pass tween property?
Jeremy Davis
jwdavis1981 at gmail.com
Tue Jan 19 12:00:07 PST 2010
Below i took values from strings including the property names, pushed to a
function and looped through and added them to an object which then passed to
Tweener afterwards.
import caurina.transitions.Tweener;
var prop:Array = new Array();
prop.push("x");
prop.push("y");
prop.push("time");
prop.push("transition");
var val:Array = new Array();
val.push(100);
val.push(10);
val.push(1);
val.push("easeInOutBack");
buildObj(prop, val);
function buildObj(props:Array, values:Array) {
var myObj:Object = new Object();
for(var i:int = 0; i < props.length; i++) {
myObj[props[i]] = values[i];
}
Tweener.addTween(obj,{base:myObj});
}
Ive actually used xml nodeNames as property names and passed to a function
to convert to an object. ex:
<x>100</x>
<y>200</y>
<time>1</time>
<alpha>1</alpha>
<transition>easeInOutBack</transition>
On Tue, Jan 19, 2010 at 2:38 PM, Zeh Fernando <zeh at zehfernando.com> wrote:
> You can do it like this:
>
> function tweenMe(who:Object, whichProp:String, howMuch:Number,
> howLong:Number, transition:String, delayTime:Number):void {
> var obj:Object = {time:howLong, transition:transition,
> delay:delayTime};
> obj[whichProp] = howMuch;
> Tweener.addTween(who, obj);
> }; //End tweenMe
>
> Zeh
>
> On Tue, Jan 19, 2010 at 2:26 PM, Mitch Rosefelt <
> PixelDroid at thepixelfarm.com> wrote:
>
>> Hi all:
>> Is it possible to pass the property for a tween thru a var?
>> For example, here is a general purpose tween function:
>>
>> function tweenMe(who:Object, whichProp:String, howMuch:Number,
>> howLong:Number, transition:String, delayTime:Number):void
>> {
>> Tweener.addTween(who, {whichProp: howMuch, time:howLong,
>> transition:transition, delay:delayTime});
>> }; //End tweenMe
>>
>> which could be invoked with:
>>
>> tweenMe (timelineMC, "x", timelineScrollAmt, 1.5, "easeInOutQuart", 0 );
>>
>> which generates this error:
>>
>> ## [Tweener] Error: The property 'whichProp' doesn't seem to be a normal
>> object property of [object MovieClip] or a registered special property.
>>
>> I've also tried it w/not typing the property, but get the same error.
>>
>> Thanks much.
>> Mitch
>>
>>
>>
>> _______________________________________________
>> Tweener mailing list
>> Tweener at lists.caurinauebi.com
>> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>>
>>
>
> _______________________________________________
> Tweener mailing list
> Tweener at lists.caurinauebi.com
> http://lists.caurinauebi.com/listinfo.cgi/tweener-caurinauebi.com
>
>
--
Thanks,
Jeremy Davis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.caurinauebi.com/pipermail/tweener-caurinauebi.com/attachments/20100119/40906793/attachment.htm>
More information about the Tweener
mailing list