You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2022/10/07 01:54:56 UTC

[royale-asjs] branch develop updated: Improvements in base Tween class - avoid RTE when calling end() before play() as an example. - also default easing function does not need to be an instance method.

This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new e706759483 Improvements in base Tween class - avoid RTE when calling end() before play() as an example. - also default easing function does not need to be an instance method.
     new 9ff7bb49e2 Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
e706759483 is described below

commit e706759483826c767abf5c71ff3a149842c9fa39
Author: greg-dove <gr...@gmail.com>
AuthorDate: Fri Oct 7 14:53:24 2022 +1300

    Improvements in base Tween class
    - avoid RTE when calling end() before play() as an example.
    - also default easing function does not need to be an instance method.
---
 .../main/royale/org/apache/royale/effects/Tween.as | 24 ++++++++++------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/frameworks/projects/Effects/src/main/royale/org/apache/royale/effects/Tween.as b/frameworks/projects/Effects/src/main/royale/org/apache/royale/effects/Tween.as
index f78b55373c..142bfd933b 100644
--- a/frameworks/projects/Effects/src/main/royale/org/apache/royale/effects/Tween.as
+++ b/frameworks/projects/Effects/src/main/royale/org/apache/royale/effects/Tween.as
@@ -195,6 +195,15 @@ public class Tween extends Effect
     //
     //--------------------------------------------------------------------------
 
+    /**
+     *  @private
+     */
+    private static function defaultEasingFunction(t:Number, b:Number,
+                                                  c:Number, d:Number):Number
+    {
+        return c / 2 * (Math.sin(Math.PI * (t / d - 0.5)) + 1) + b;
+    }
+
     /**
      *  @private
      *  @royaleignorecoercion org.apache.royale.core.IEffectTimer
@@ -570,21 +579,12 @@ public class Tween extends Effect
 
         if (_invertValues)
             currentTime = duration - currentTime;
-
-        return userEquation(currentTime, startValue,
+        const eq:Function = userEquation || (userEquation = defaultEasingFunction);
+        return eq(currentTime, startValue,
                 endValue - startValue,
                 duration);
     }
 
-    /**
-     *  @private
-     */
-    private function defaultEasingFunction(t:Number, b:Number,
-                                           c:Number, d:Number):Number
-    {
-        return c / 2 * (Math.sin(Math.PI * (t / d - 0.5)) + 1) + b;
-    }
-
     /**
      *  Stops the tween, ending it without dispatching an event or calling
      *  the Tween's endFunction or <code>onTweenEnd()</code>.
@@ -676,8 +676,6 @@ public class Tween extends Effect
     override public function play():void
     {
         if (uid == 0) {
-            if (userEquation == null)
-                userEquation = defaultEasingFunction;
             Tween.addTween(this);
         }
     }