This is an automated email from the ASF dual-hosted git repository. piotrz 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 6647d85 MXRoyale: Add Timer implementation with TimerEvent. Timer extends org.apache.royale.utils.Timer and dispatch TimerEvent.TIMER_COMPLETE 6647d85 is described below commit 6647d85103f89b45baa4b61560bb8331dfdff8bd Author: pzarzycki <piotr.zarzy...@wipro.com> AuthorDate: Fri Oct 23 12:28:11 2020 +0100 MXRoyale: Add Timer implementation with TimerEvent. Timer extends org.apache.royale.utils.Timer and dispatch TimerEvent.TIMER_COMPLETE --- .../MXRoyale/src/main/royale/MXRoyaleClasses.as | 3 + .../src/main/royale/mx/events/TimerEvent.as | 115 +++++++++++++++++++++ .../MXRoyale/src/main/royale/mx/utils/Timer.as | 70 +++++++++++++ 3 files changed, 188 insertions(+) diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as index d091291..9aeed54 100644 --- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as +++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as @@ -352,6 +352,9 @@ internal class MXRoyaleClasses import mx.utils.NameUtil; NameUtil; import mx.core.BitmapAsset; BitmapAsset; + + import mx.events.TimerEvent; TimerEvent; + import mx.utils.Timer; Timer; } } diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/events/TimerEvent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/events/TimerEvent.as new file mode 100644 index 0000000..50d625a --- /dev/null +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/events/TimerEvent.as @@ -0,0 +1,115 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 mx.events +{ + import org.apache.royale.events.Event; + import org.apache.royale.events.IRoyaleEvent; + + /** + * The TimeEvent class represents event objects specific to Timer + * + * @see mx.utils.Timer + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + * @productversion Royale 0.9.8 + */ + public class TimerEvent extends Event + { + //-------------------------------------------------------------------------- + // + // Class constants + // + //-------------------------------------------------------------------------- + /** + * + * @eventType timerComplete + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + * @productversion Royale 0.9.8 + */ + public static const TIMER:String = "timer"; + + /** + * + * @eventType timerComplete + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + * @productversion Royale 0.9.8 + */ + public static const TIMER_COMPLETE:String = "timerComplete"; + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @param type The event type; indicates the action that caused the event. + * + * @param bubbles Specifies whether the event can bubble up the display list hierarchy. + * + * @param cancelable Specifies whether the behavior associated with the event can be prevented. + * + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + * @productversion Royale 0.9.8 + */ + public function TimerEvent(type:String, bubbles:Boolean = false, + cancelable:Boolean = false) + { + super(type, bubbles, cancelable); + } + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + //-------------------------------------------------------------------------- + // + // Overridden methods: Event + // + //-------------------------------------------------------------------------- + + /** + * @private + */ + override public function cloneEvent():IRoyaleEvent + { + return new TimerEvent(type, bubbles, cancelable); + } + } +} diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/utils/Timer.as b/frameworks/projects/MXRoyale/src/main/royale/mx/utils/Timer.as new file mode 100644 index 0000000..439c5fc --- /dev/null +++ b/frameworks/projects/MXRoyale/src/main/royale/mx/utils/Timer.as @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 mx.utils +{ + + import mx.events.TimerEvent; + + import org.apache.royale.utils.Timer; + + //-------------------------------------- + // Events + //-------------------------------------- + + /** + * Dispatched when timer stops + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.8 + */ + [Event(name="timerComplete", type="org.apache.royale.events.Event")] + + + /** + * The Timer class dispatches events based on a delay + * and repeat count. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.8 + * + * @royalesuppresspublicvarwarning + */ + public class Timer extends org.apache.royale.utils.Timer + { + public function Timer(delay:Number, repeatCount:int = 0) + { + super(delay, repeatCount); + } + + override public function stop():void + { + super.stop(); + COMPILE::JS + { + if (!running) { + dispatchEvent(new TimerEvent('timerComplete')); + } + } + } + } +}