2025-01-15 19:28:55 +01:00

83 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en"><!-- use theme color or fallback -->
<!--use textcolor from settings, otherwise create a contrasting color to theme color-->
<head><meta charset="utf-8"/><link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet"/><link href="../bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet"/><link href="../bootstrap/css/bootstrap-select.min.css" rel="stylesheet"/><link href="http://fonts.googleapis.com/css?family=Open+Sans:400,700,700italic,400italic" rel="stylesheet" type="text/css"/><link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,600,600italic,400" rel="stylesheet" type="text/css"/><link href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css" rel="stylesheet" type="text/css"/><script src="../jquery-1.9.1.min.js"></script><script src="../bootstrap/js/bootstrap.min.js"></script><script src="../bootstrap/js/bootstrap-select.min.js"></script><link href="../styles.css" rel="stylesheet"/><link href="../haxe-nav.css" rel="stylesheet"/><script type="text/javascript">var dox = {rootPath: "../",platforms: ["Neko","Android","Flash","iOS","macOS","Linux","HTML5","Windows"]};</script><script type="text/javascript" src="../nav.js"></script><script type="text/javascript" src="../index.js"></script><link rel="icon" href="../favicon.ico" type="image/x-icon"></link><title>haxe.Timer - API Reference</title><meta name="description" content="The Timer class allows you to create asynchronous timers on platforms that
support events."/></head><body><style>
a, code .type {
color: #24afc4;
}
.navbar .brand {
display: inline-block;
float: none;
text-shadow: 0 0 0 transparent;
}
.nav-list>.active>a.treeLink, .nav-list>.active>a.treeLink:hover, .nav-list>.active>a.treeLink:focus {
background: #24afc4;
color: #ffffff;
text-shadow: 0 0 0 transparent;
}
.navbar .container {
width: 940px ;
}
@media (max-width: 767px) {
.navbar .container {
width: auto;
}
}
@media (max-width: 979px) and (min-width: 768px) {
.navbar .container {
width: 724px;
}
}
@media (min-width: 1200px) {
.navbar .container {
width: 1170px;
}
}
.navbar .container img {
margin: 5px 0 0 4px;
}
</style><nav class="nav"><div class="navbar"><div class="navbar-inner" style="background:#FAFAFA; border-bottom:1px solid rgba(0,0,0,.09)"><div class="container"><a class="brand" href="http://www.openfl.org"><img alt="" src="http://www.openfl.org/images/logo.png"/></a><a class="brand" style="color:#777777" href="../">API Reference</a></div></div></div></nav><div class="container main-content"><div class="row-fluid"><div class="span3"><div class="well sidebar-nav"><form class="form-search" id="searchForm"><div class="input-prepend input-block-level"><span class="add-on"><i class="icon-search"></i></span><input id="search" type="text" placeholder="Search" autocomplete="off"/></div></form><div class="dropdown"><select id="select-platform" class="selectpicker" title="Filter by platform" data-width="100%"><option value="all" selected="true">All Platforms</option><option>Neko</option><option>Android</option><option>Flash</option><option>iOS</option><option>macOS</option><option>Linux</option><option>HTML5</option><option>Windows</option></select></div></div><div class="well sidebar-nav"><div id="nav"></div></div></div><div class="span9"><div class="page-header"><h1><small>class</small> Timer</h1><h4><small>package <a href="../haxe/index.html">haxe</a></small></h4> <p class="availability"><hr/><em>Available on all platforms</em></p></div><div class="body"><div class="doc doc-main"><div class="indent"><p>The Timer class allows you to create asynchronous timers on platforms that
support events.</p>
<p>The intended usage is to create an instance of the Timer class with a given
interval, set its run() method to a custom function to be invoked and
eventually call stop() to stop the Timer.</p>
<p>Note that a running Timer may or may not prevent the program to exit
automatically when main() returns.</p>
<p>It is also possible to extend this class and override its run() method in
the child class.</p></div></div><h3 class="section">Constructor</h3><div class="fields"><div class="field "><a name="new"></a><h3><p><code><a href="#new"><span class="identifier">new</span></a> (<span style="white-space:nowrap">time_ms:<a class="type" title="The standard Int type." href="../Int.html">Int</a></span>)</code></p></h3><p class="availability"><em>Available on Flash, HTML5</em></p><div class="doc"><p>Creates a new timer that will run every <code>time_ms</code> milliseconds.</p>
<p>After creating the Timer instance, it calls <code>this.<a href="#run">run</a></code> repeatedly,
with delays of <code>time_ms</code> milliseconds, until <code>this.<a href="#stop">stop</a></code> is called.</p>
<p>The first invocation occurs after <code>time_ms</code> milliseconds, not
immediately.</p>
<p>The accuracy of this may be platform-dependent.</p></div></div><div class="field "><a name="new"></a><h3><p><code><a href="#new"><span class="identifier">new</span></a> (<span style="white-space:nowrap">time:<a class="type" title="The standard Float type, this is a double-precision IEEE 64bit float." href="../Float.html">Float</a></span>)</code></p></h3><p class="availability"><em>Available on Neko, Android, iOS, macOS, Linux, Windows</em></p><div class="doc"><p>Creates a new timer that will run every <code>time_ms</code> milliseconds.</p>
<p>After creating the Timer instance, it calls <code>this.<a href="#run">run</a></code> repeatedly,
with delays of <code>time_ms</code> milliseconds, until <code>this.<a href="#stop">stop</a></code> is called.</p>
<p>The first invocation occurs after <code>time_ms</code> milliseconds, not
immediately.</p>
<p>The accuracy of this may be platform-dependent.</p></div></div></div><h3 class="section">Methods</h3><div class="fields"><div class="field "><a name="run"></a><h3><p><code><span class="label">dynamic</span> <a href="#run"><span class="identifier">run</span></a> ():<a class="type" title="The standard Void type." href="../Void.html">Void</a></code></p></h3><div class="doc"><p>This method is invoked repeatedly on <code>this</code> Timer.</p>
<p>It can be overridden in a subclass, or rebound directly to a custom
function:</p>
<pre><code>var timer = new haxe.Timer(1000); // 1000ms delay
timer.run = function() { ... }
</code></pre>
<p>Once bound, it can still be rebound to different functions until <code>this</code>
Timer is stopped through a call to <code>this.<a href="#stop">stop</a></code>.</p></div></div><div class="field "><a name="stop"></a><h3><p><code><a href="#stop"><span class="identifier">stop</span></a> ():<a class="type" title="The standard Void type." href="../Void.html">Void</a></code></p></h3><div class="doc"><p>Stops <code>this</code> Timer.</p>
<p>After calling this method, no additional invocations of <code>this.<a href="#run">run</a></code>
will occur.</p>
<p>It is not possible to restart <code>this</code> Timer once stopped.</p></div></div></div><h3 class="section">Static methods</h3><div class="fields"><div class="field "><a name="delay"></a><h3><p><code><span class="label">static</span><a href="#delay"><span class="identifier">delay</span></a> (<span style="white-space:nowrap">f:<a class="type" title="The standard Void type." href="../Void.html">Void</a>&nbsp;&#8209;&gt;&nbsp;<a class="type" title="The standard Void type." href="../Void.html">Void</a>,</span> <span style="white-space:nowrap">time:<a class="type" title="The standard Int type." href="../Int.html">Int</a></span>):<a class="type" title="The Timer class allows you to create asynchronous timers on platforms that support events." href="../haxe/Timer.html">Timer</a></code></p></h3><p class="availability"><em>Available on Neko, Android, iOS, macOS, Linux, Windows</em></p><div class="doc"><p>Invokes <code>f</code> after <code>time_ms</code> milliseconds.</p>
<p>This is a convenience function for creating a new Timer instance with
<code>time_ms</code> as argument, binding its run() method to <code>f</code> and then stopping
<code>this</code> Timer upon the first invocation.</p>
<p>If <code>f</code> is null, the result is unspecified.</p></div></div><div class="field "><a name="delay"></a><h3><p><code><span class="label">static</span><a href="#delay"><span class="identifier">delay</span></a> (<span style="white-space:nowrap">f:<a class="type" title="The standard Void type." href="../Void.html">Void</a>&nbsp;&#8209;&gt;&nbsp;<a class="type" title="The standard Void type." href="../Void.html">Void</a>,</span> <span style="white-space:nowrap">time_ms:<a class="type" title="The standard Int type." href="../Int.html">Int</a></span>):<a class="type" title="The Timer class allows you to create asynchronous timers on platforms that support events." href="../haxe/Timer.html">Timer</a></code></p></h3><p class="availability"><em>Available on Flash, HTML5</em></p><div class="doc"><p>Invokes <code>f</code> after <code>time_ms</code> milliseconds.</p>
<p>This is a convenience function for creating a new Timer instance with
<code>time_ms</code> as argument, binding its run() method to <code>f</code> and then stopping
<code>this</code> Timer upon the first invocation.</p>
<p>If <code>f</code> is null, the result is unspecified.</p></div></div><div class="field "><a name="measure"></a><h3><p><code><span class="label">static</span><a href="#measure"><span class="identifier">measure</span></a>&lt;<span class="type">T</span>&gt; (<span style="white-space:nowrap">f:<a class="type" title="The standard Void type." href="../Void.html">Void</a>&nbsp;&#8209;&gt;&nbsp;<span class="type">T</span>,</span> <span style="white-space:nowrap">?pos:<a class="type" title="PosInfos is a magic type which can be used to generate position information into the output for debugging use." href="../haxe/PosInfos.html">PosInfos</a></span>):<span class="type">T</span></code></p></h3><div class="doc"><p>Measures the time it takes to execute <code>f</code>, in seconds with fractions.</p>
<p>This is a convenience function for calculating the difference between
Timer.stamp() before and after the invocation of <code>f</code>.</p>
<p>The difference is passed as argument to Log.trace(), with "s" appended
to denote the unit. The optional <code>pos</code> argument is passed through.</p>
<p>If <code>f</code> is null, the result is unspecified.</p></div></div><div class="field "><a name="stamp"></a><h3><p><code><span class="label">static</span><span class="label">inline</span> <a href="#stamp"><span class="identifier">stamp</span></a> ():<a class="type" title="The standard Float type, this is a double-precision IEEE 64bit float." href="../Float.html">Float</a></code></p></h3><div class="doc"><p>Returns a timestamp, in seconds with fractions.</p>
<p>The value itself might differ depending on platforms, only differences
between two values make sense.</p></div></div></div></div></div></div></div><footer class="section site-footer" style="background:#FAFAFA"><div class="container"><div class="copyright"><p style="color:#777777">&copy; 2017 &nbsp;<a style="color:#777777" href="http://www.openfl.org">http://www.openfl.org</a></p></div></div></footer><script src="..//highlighter.js"></script><link href="../highlighter.css" rel="stylesheet"/></body></html>