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

carlosrovira 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 2ec43a4  add TimerEvent and timerComplete event
2ec43a4 is described below

commit 2ec43a4503588dd1b49019c1d75ba8ee3613982d
Author: Carlos Rovira <[email protected]>
AuthorDate: Thu Nov 29 15:01:30 2018 +0100

    add TimerEvent and timerComplete event
---
 .../projects/Core/src/main/royale/CoreClasses.as   |  1 +
 .../royale/org/apache/royale/events/TimerEvent.as  | 68 ++++++++++++++++++++++
 .../main/royale/org/apache/royale/utils/Timer.as   |  1 +
 3 files changed, 70 insertions(+)

diff --git a/frameworks/projects/Core/src/main/royale/CoreClasses.as 
b/frameworks/projects/Core/src/main/royale/CoreClasses.as
index e28bbda..ac4158b 100644
--- a/frameworks/projects/Core/src/main/royale/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/royale/CoreClasses.as
@@ -155,6 +155,7 @@ import org.apache.royale.events.ItemRemovedEvent; 
ItemRemovedEvent;
        import org.apache.royale.core.StyleChangeNotifier; StyleChangeNotifier;
        import org.apache.royale.events.CustomEvent; CustomEvent;
     import org.apache.royale.events.Event; Event;
+    import org.apache.royale.events.TimerEvent; TimerEvent;
        import org.apache.royale.events.CloseEvent; CloseEvent;
        import org.apache.royale.events.CollectionEvent; CollectionEvent;
     import org.apache.royale.events.ProgressEvent; ProgressEvent;
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/events/TimerEvent.as
 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/TimerEvent.as
new file mode 100644
index 0000000..c20b491
--- /dev/null
+++ 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/events/TimerEvent.as
@@ -0,0 +1,68 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.royale.events
+{
+    public class TimerEvent extends Event
+    {
+        /**
+         *  Defines the value of the type property of a timer event object.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.0
+         */
+        public static const TIMER:String = "timer";
+        
+        /**
+         *  Defines the value of the type property of a timerComplete event 
object.
+         *  
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.0
+         */
+        public static const TIMER_COMPLETE:String = "timerComplete";
+
+        /**
+                * Creates an Event object with specific information relevant 
to timer events.
+         * 
+         * Constructor.
+                *
+                * @param type The name of the event.
+                * @param bubbles Whether the event bubbles.
+                * @param cancelable Whether the event can be canceled.
+                *
+                * @langversion 3.0
+                * @playerversion Flash 10.2
+                * @playerversion AIR 2.6
+                * @productversion Royale 0.0
+                */
+               public function TimerEvent(type:String, bubbles:Boolean = 
false, cancelable:Boolean = false)
+               {
+                       super(type, bubbles, cancelable);
+               }
+        
+        COMPILE::JS
+        public function toString():String
+        {
+            return "[TimerEvent type=" + type + " bubbles=" + bubbles + " 
cancelable=" + cancelable + "]";
+        }
+    }
+}
\ No newline at end of file
diff --git 
a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/Timer.as 
b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/Timer.as
index ddbee84..ab4e1fe 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/Timer.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/Timer.as
@@ -185,6 +185,7 @@ public class Timer extends EventDispatcher
         _currentCount++;
         if (repeatCount > 0 && currentCount >= repeatCount) {
             stop();
+            dispatchEvent(new Event('timerComplete'));
         }
         
         dispatchEvent(new Event('timer'));

Reply via email to