From: Ray C. <rc...@gm...> - 2006-09-04 11:14:32
|
Hi, I've made some changes to NSAnimation and related classes. There are now 2 main classes to use: ASAnimation and NSAnimation. No, that's not a typo, there are 2 such classes. What ASAnimation does is allow the delegate with the method animationDidAdvance, which is not part of the Cocoa specs. This is an alternative to what Apple recommends: subclassing NSAnimation and overriding the setCurrentProgress method. I find this too cumbersome, so the framework now contains ASAnimation which saves you the trouble of subclassing NSAnimation. I've also added more constants to NSAnimationCurve and removed methods like setBegin/setChange such that full Cocoa-spec compliance is ensured in NSAnimation. See /trunk/test/org.actionstep.test.ASTestAnimation for an example. To animate in the RP(Robert Penner)-style, you would do this previously: >>> anim.setBegin(sx); anim.setChange(dx); anim.setFrameRate(30); anim.setDelegate({ animationDidAdvance:function(foo:NSAnimation):Void { mc._x = foo.currentValue(); } }); <<< Now you to do the same thing, you will do: >>> // no more setBegin/Change anim.setFrameRate(1/30); //note change in frame rate anim.setDelegate({ animationDidAdvance:function(foo:NSAnimation):Void { mc._x = sx + foo.currentValue() * dx; } }); <<< -currentValue is always between 0 and 1, so you can think of it as a fraction of the value to animate. Do not confuse this with -currentProgress which tells you how much of the animation has completed. -- Cheers, Ray Chuan |