views:

23

answers:

1

Hey guys,

This is probably something simple but I'm scratching my head over easing with the Animate class in Flex 4.

Basically I'm just trying to set easing via:

anim.easer = spark.effects.easing.EaseInOutBase(EasingFraction.IN_OUT);

however, it complains, saying

Type Coercion failed: cannot convert 0.5 to spark.effects.easing.EaseInOutBase.

Which would be fine, except... the constructor argument is a Number, not an instance of EaseInOutBase. Am I missing something? All of Google's results suggest that this should be defined via MXML, but I just feel... dirty doing it - rather, defining something that is purely programmatic with markup. I know that's half the nature of Flex, but still, I like to keep most of my logic/configuration in AS3.

If there's a better way to animate with easing than using Animate with its easer property (eg, if this isn't the right way), feel free to suggest an alternative - still a bit new to Flex.

+2  A: 

Yes. You are certainly missing something... :) You are missing the new keyword.

Your code is trying to cast EasingFraction.IN_OUT to the type EaseInOutBase... which is why you get that seemingly (but completely appropriate) error.

Instead:

anim.easer = new spark.effects.easing.EaseInOutBase(EasingFraction.IN_OUT);

:)

Brian Genisio
Indeed I am. :) That'll teach me to code when exhausted. Thank you!
mway