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
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"
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?
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);
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);
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);
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
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 /////////////////////////////////////////////////////////////////////////////
tweenType should NOT be a string. it IS a function. again, there are no quotes encasing: mx.transitions.easing.Elastic;
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... :(
then it's a combobox limitation. it can't handle data that references a function.
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
Don't see what you're looking for? Try a search.
|