Gordon beat me to it. . .
This works for me: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:Script> <![CDATA[ import mx.effects.easing.*; private var myBounce:Bounce; private function changeEasing():void { var func:Function = getDefinitionByName("mx.effects.easing.Bounce").easeIn; myResize.easingFunction = func; } ]]> </mx:Script> <mx:Resize id="myResize" widthBy="50" duration="1000"/> <mx:VBox width="100" height="100" backgroundColor="0x0000DD" mouseDownEffect="{myResize}"/> <mx:Button label="Change easing" click="changeEasing()"/> </mx:Application> Note that the class name is case sensitive. Jason ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Gordon Smith Sent: Monday, November 26, 2007 4:56 PM To: [email protected] Subject: RE: [flexcoders] Re: Dynamically Changing Easing Function Again > This is aggravatingly difficult to do. You don't say what's going wrong, but I suspect that getDefinitionByName() is returning null when you pass it a string like "mx.effects.easing.Cubic". That's because the Cubic class doesn't exist in your SWF... the MXML compiler has no way of knowing that your app needs it, so it doesn't link it in. One way to get it to be linked in is to declare a static var of that type. Note that simply importing it is NOT sufficient to link it in. - Gordon <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " layout="absolute"> <mx:Script> <![CDATA[ import mx.effects.easing.Cubic; private static var cubicDependency:Cubic; private function doit():void { var easingFunction:String = "Cubic"; trace(getDefinitionByName("mx.effects.easing." + easingFunction).easeIn); } ]]> </mx:Script> <mx:Button click="doit()"/> </mx:Application> ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Amy Sent: Monday, November 26, 2007 11:56 AM To: [email protected] Subject: [flexcoders] Re: Dynamically Changing Easing Function Again --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "ben.clinkinbeard" <[EMAIL PROTECTED]> wrote: > > FYI, in case you haven't seen this one: > http://www.madeinflex.com/img/entries/2007/05/customeasingexplorer.htm <http://www.madeinflex.com/img/entries/2007/05/customeasingexplorer.htm> l Yes, I had seen that, which is why I made sure I mentioned that I was trying to explore the built-in functions and not making a custom function. I figured people would be less likely to send me to that ;- ). However, if you see anything in what that is doing that would work for what I need, maybe I have missed something. I would love it if I could find a way to use this as just a generic easing explorer for my own objects to see what the in-built easing functions do. This is aggravatingly difficult to do...at this point it would have been far faster to just do a swich case and hard-code in all the easing functions. Not very dynamic or extensible, though, which kind of goes against the spirit of Flex. -Amy > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Amy" <amyblankenship@> wrote: > > > > I am trying to create an easing function explorer to be able to compare > > the existing easing functions. However, I am having a problem with the > > syntax to change out the function at runtime. I feel like I am really > > close here, but I am at a loss as to what else to try. Here is the > > function I am using. > > > > private function onListChange(e:Event):void { > > easingFunction = e.target.selectedItem.label; > > goToBottom.easingFunction = getDefinitionByName > > ("mx.effects.easing."+easingFunction).easeIn; > > goToTop.easingFunction = getDefinitionByName > > ("mx.effects.easing."+easingFunction).easeIn; > > } > > >

