all groups > flash actionscript > march 2007 >
You're in the

flash actionscript

group:

syntax question (for Tween class pros maybe?)



syntax question (for Tween class pros maybe?) stephan.k
3/29/2007 11:12:04 PM
flash actionscript: I've posted it earlier but no one replied. Maybe my post was a little
confusing. I'll try again.

Here is the code ( > comboFunc is the problem child):

var tweenType = [_root.tweenOptionsComboBox.selectedItem.data];
var easeType = [_root.easeOptionsComboBox.selectedItem.data];
var comboFunc = [tweenType+easeType];
this.tween = new Tween(this.ring, _xscale,comboFunc, 0,100,5, true);

Basically there are two comboBox dropdown menus on the root. Listing all
Tween options (Regular, Bounce, Elastic...) and all easing options (easeIn,
easeOut...) How can put the two dynamically together without a long switch
statement...

any insight appreciated.

Thanks

Stephan


Re: syntax question (for Tween class pros maybe?) kglad
3/29/2007 11:35:14 PM
Re: syntax question (for Tween class pros maybe?) stephan.k
3/29/2007 11:38:06 PM
they're both Strings as far as I understand.

I'm storing in the data fields of the combobox the words: [Regular, Back,
Elastic, ...]
and same in the ease combobox: [easeIn,easeOur,easeInOut]

am I supposed to put those in like this: "Regular","Back","Elastic"


Re: syntax question (for Tween class pros maybe?) stephan.k
3/30/2007 12:06:21 AM
I see what you mean by a reference to the object.

I've now replaced the["Regular","Bounce",....] by
[mx.transitions.Tween.Regular,mx.transitions.Tween.Bounce,...]
The easing combo data is now : ["easeIn","easeOut",...]

var tweenType = [_root.growingTween.selectedItem.data];
var easeType = [_root.growingEase.selectedItem.data];
this.tween.stop();
this.tween = new TweenExtended(this.ring,
["_xscale","_yscale"],tweenType[easeType], [this.ring._xscale,
this.ring._yscale], [_root.getMinSize(),_root.getMinSize()],
_root.getShrinkSpeed(), true);


Still doesn't work. I feel this is close though no?


Re: syntax question (for Tween class pros maybe?) kglad
3/30/2007 12:14:08 AM
if you use the object: mx.transitions.easing.Elastic (for example) for your
tweenType data and the string: "easeIn" (for example), for your easeType data,
you can use:



this.tween = new Tween(this.ring, _xscale,tweenType[easeType], 0,100,5, true);
Re: syntax question (for Tween class pros maybe?) stephan.k
3/30/2007 12:24:21 AM
hmm I've just tried that. replaced it with the mx.transitions,easing path...
no luck. the following trace returns undefined.


var tweenType = [_root.growingTween.selectedItem.data];
var easeType = [_root.growingEase.selectedItem.data];
trace(tweenType[easeType])
this.tween = new TweenExtended(this.ring,
["_xscale","_yscale"],tweenType[easeType], [this.ring._xscale,
this.ring._yscale], [_root.getMinSize(),_root.getMinSize()],
_root.getShrinkSpeed(), true);

Re: syntax question (for Tween class pros maybe?) stephan.k
3/30/2007 12:34:33 AM
I'm getting a [type object] trace with the "Function()" casting function.

But nothing moves...? (it does move if I type in the Regular.easeIn manually)

Here's the code:
var tweenType = [_root.growingTween.selectedItem.data];
var easeType = [_root.growingEase.selectedItem.data];

trace(Function(tweenType[easeType]));

this.tween = new TweenExtended(this.ring,
["_xscale","_yscale"],Function(tweenType[easeType]), [this.ring._xscale,
this.ring._yscale], [_root.getMinSize(),_root.getMinSize()],
_root.getShrinkSpeed(), true);

Re: syntax question (for Tween class pros maybe?) kglad
3/30/2007 1:36:29 AM
i don't know why you're using array notation. but if:



_root.growingTween.selectedItem.data = mx.transitions.easing.Elastic;
_root.growingEase.selectedItem.data = "easeIn"

// and

tweenType = _root.growingTween.selectedItem.data;
easeType = _root.growingEase.selectedItem.data;

// then,

this.tween = new Tween(this.ring, _xscale,tweenType[easeType], 0,100,5, true);

// will work if this.ring is a movieclip
Re: syntax question (for Tween class pros maybe?) stephan.k
3/30/2007 2:22:11 AM
Hmm That's so strange. It still doesn't work. I've taken out the array
notation as you've suggested in your last message.

The Tracing in the following code:
---------------------------------------------
var tweenType = _root.growingTween.selectedItem.data;
var easeType = _root.growingEase.selectedItem.data;

trace("tweenType : "+tweenType);
trace("easeType : "+easeType);
trace("tweenType[easeType] : "+tweenType[easeType]);
/////////////////////////////////////////////////////////////////////////////

...prints the following messages in the output window:
-------------------------------------------------
tweenType : mx.transitions.easing.Regular
easeType : easeIn
tweenType[easeType] : undefined
/////////////////////////////////////////////////////////////////////////////


Re: syntax question (for Tween class pros maybe?) kglad
3/30/2007 4:00:18 AM
tweenType should NOT be a string. it IS a function.

again, there are no quotes encasing:

mx.transitions.easing.Elastic;
Re: syntax question (for Tween class pros maybe?) stephan.k
3/30/2007 4:10:33 AM
I've double checked the data parameters in the combo boxes:

No quotes encasing the tweens:
[mx.transitions.easing.Regular,mx.transitions.easing.Elastic,...]

Quotes encasing the easings:
["easeIn","easeOur","easeInOut"]

no luck... :(


Re: syntax question (for Tween class pros maybe?) kglad
3/30/2007 4:57:03 AM
then it's a combobox limitation. it can't handle data that references a function.

Re: syntax question (for Tween class pros maybe?) stephan.k
3/30/2007 5:58:22 AM
Thanks a lot for debugging this with me. I appreciate it.

I ended up storing the tween values as strings as well and then using a switch
command to categorize the different Tweens. It works... what else could I
possibly want.

Good night.

Cheers

Stephan
Re: syntax question (for Tween class pros maybe?) kglad
3/30/2007 2:38:55 PM
AddThis Social Bookmark Button