<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Lesser Known Operators:&#160; Modulo (%)</title>
	<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Wed, 19 Nov 2008 03:46:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-13754</link>
		<pubDate>Tue, 23 Jan 2007 13:19:13 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-13754</guid>
					<description>NSurveyor,

Haha ... yes, 100 / 50 is 2.  Man, I'm a goof.  That's two simple arithmetic errors for me in either the article or the comments.</description>
		<content:encoded><![CDATA[<p>NSurveyor,</p>
<p>Haha &#8230; yes, 100 / 50 is 2.  Man, I&#8217;m a goof.  That&#8217;s two simple arithmetic errors for me in either the article or the comments.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: NSurveyor</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-13680</link>
		<pubDate>Tue, 23 Jan 2007 04:11:51 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-13680</guid>
					<description>&quot;var ratio = _totalframes / _currentframe
// e.g. 100 / 50 = 0.5&quot;

Shouldn't it be _currentframe / _totalframes
100 / 50 is ... whoops! 2 :)

and also, you can simply divide the frame you are at by the frame rate to get seconds. We see that this is identical to the originally proposed method... (_currentframe / _totalframes) * (_totalframes/24) = _currentframe / 24</description>
		<content:encoded><![CDATA[<p>&#8220;var ratio = _totalframes / _currentframe<br />
// e.g. 100 / 50 = 0.5&#8243;</p>
<p>Shouldn&#8217;t it be _currentframe / _totalframes<br />
100 / 50 is &#8230; whoops! 2 <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>and also, you can simply divide the frame you are at by the frame rate to get seconds. We see that this is identical to the originally proposed method&#8230; (_currentframe / _totalframes) * (_totalframes/24) = _currentframe / 24
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-6247</link>
		<pubDate>Mon, 20 Nov 2006 13:29:08 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-6247</guid>
					<description>Thanks, Paul!  :)</description>
		<content:encoded><![CDATA[<p>Thanks, Paul!  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Paul Mayne</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-6210</link>
		<pubDate>Mon, 20 Nov 2006 05:25:48 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-6210</guid>
					<description>Thank you, exactly what I needed to learn. Great site, keep it up.</description>
		<content:encoded><![CDATA[<p>Thank you, exactly what I needed to learn. Great site, keep it up.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3420</link>
		<pubDate>Tue, 03 Oct 2006 21:17:01 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3420</guid>
					<description>Icarus,

Wow!  For what you're doing, I would probably use specifically video-related properties, such as &lt;code&gt;FLVPlayback.playheadTime&lt;/code&gt; or, say, &lt;code&gt;NetStream.time&lt;/code&gt; (see related classes in the ActionScript 2.0 Language Reference for details).

If you really want to convert a timeline-based video to HH:MM:SS:frames, you're going to have to be prepared for inaccurate results, not only because the timeline cannot have fractional frames, but also because the arithmetic may be more or less &quot;chunky&quot; depending on the framerate ratios.

That said, you'd have to know your SWF's framerate going in.  Let's say your SWF's framerate is 24fps.  If the SWF has 100 frames &amp;#8212; because that's how may frames the video requires &amp;#8212; then the video takes approximately 4.17 seconds to play from start to finish (100 frames divided by 24fps = 4.17).  If you're at frame one, zero seconds have passed.  If you're at frame 100, 4.17 seconds have passed.  With me so far?  If you're at frame 50, 2.09 seconds have passed.

So take note of the SWF's &lt;code&gt;_currentframe&lt;/code&gt; value and compare that against its &lt;code&gt;_totalframes&lt;/code&gt; value to find your ratio.

&lt;pre&gt;&lt;code&gt;var ratio = _totalframes / _currentframe
// e.g. 100 / 50 = 0.5&lt;/code&gt;&lt;/pre&gt;

Then use that ratio to determine seconds.

&lt;pre&gt;&lt;code&gt;4.17 * ratio&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Icarus,</p>
<p>Wow!  For what you&#8217;re doing, I would probably use specifically video-related properties, such as <code>FLVPlayback.playheadTime</code> or, say, <code>NetStream.time</code> (see related classes in the ActionScript 2.0 Language Reference for details).</p>
<p>If you really want to convert a timeline-based video to HH:MM:SS:frames, you&#8217;re going to have to be prepared for inaccurate results, not only because the timeline cannot have fractional frames, but also because the arithmetic may be more or less &#8220;chunky&#8221; depending on the framerate ratios.</p>
<p>That said, you&#8217;d have to know your SWF&#8217;s framerate going in.  Let&#8217;s say your SWF&#8217;s framerate is 24fps.  If the SWF has 100 frames &mdash; because that&#8217;s how may frames the video requires &mdash; then the video takes approximately 4.17 seconds to play from start to finish (100 frames divided by 24fps = 4.17).  If you&#8217;re at frame one, zero seconds have passed.  If you&#8217;re at frame 100, 4.17 seconds have passed.  With me so far?  If you&#8217;re at frame 50, 2.09 seconds have passed.</p>
<p>So take note of the SWF&#8217;s <code>_currentframe</code> value and compare that against its <code>_totalframes</code> value to find your ratio.</p>
<pre><code>var ratio = _totalframes / _currentframe
// e.g. 100 / 50 = 0.5</code></pre>
<p>Then use that ratio to determine seconds.</p>
<pre><code>4.17 * ratio</code></pre>
]]></content:encoded>
				</item>
	<item>
		<title>by: Icarus</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3412</link>
		<pubDate>Tue, 03 Oct 2006 18:15:44 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3412</guid>
					<description>I'm going to try and convert _currentframe of a SWF video, to HH:MM:SS:frames
where frame is 29.97.

I tihnk i have the tools between this post and AS dictionary.

but if someone has doen it please post.</description>
		<content:encoded><![CDATA[<p>I&#8217;m going to try and convert _currentframe of a SWF video, to HH:MM:SS:frames<br />
where frame is 29.97.</p>
<p>I tihnk i have the tools between this post and AS dictionary.</p>
<p>but if someone has doen it please post.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3304</link>
		<pubDate>Fri, 29 Sep 2006 17:21:47 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3304</guid>
					<description>Matt,

Ha!  Woops.  Thanks, man.  Updating the article now.</description>
		<content:encoded><![CDATA[<p>Matt,</p>
<p>Ha!  Woops.  Thanks, man.  Updating the article now.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Matt</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3282</link>
		<pubDate>Fri, 29 Sep 2006 05:35:18 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3282</guid>
					<description>&quot;For example, 4 divided by 2 is 0, with no remainder; therefore, 4 modulo 2 equals 0.&quot;

Actually, 4 divided by 2 is 2 :)</description>
		<content:encoded><![CDATA[<p>&#8220;For example, 4 divided by 2 is 0, with no remainder; therefore, 4 modulo 2 equals 0.&#8221;</p>
<p>Actually, 4 divided by 2 is 2 <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3270</link>
		<pubDate>Thu, 28 Sep 2006 16:52:06 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3270</guid>
					<description>nirav,

How do to what &amp;#8212; the Crystal Reports thing?</description>
		<content:encoded><![CDATA[<p>nirav,</p>
<p>How do to what &mdash; the Crystal Reports thing?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: nirav</title>
		<link>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3269</link>
		<pubDate>Thu, 28 Sep 2006 16:41:20 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/actionscript-20/lesser-known-operators-modulo#comment-3269</guid>
					<description>did you figure out how to do it</description>
		<content:encoded><![CDATA[<p>did you figure out how to do it
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
