<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UnDeprived &#187; pause</title>
	<atom:link href="http://www.un-deprived.com/tag/pause/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.un-deprived.com</link>
	<description>A webdev journal of the Moninator</description>
	<lastBuildDate>Sun, 29 Aug 2010 10:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using Actionscript 2.0 to pause frames</title>
		<link>http://www.un-deprived.com/2009/others/using-actionscript-2-0-to-pause-frames/</link>
		<comments>http://www.un-deprived.com/2009/others/using-actionscript-2-0-to-pause-frames/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 15:29:03 +0000</pubDate>
		<dc:creator>Mon</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[Web Dev]]></category>
		<category><![CDATA[Actionscripts]]></category>
		<category><![CDATA[AS2]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[movie clips]]></category>
		<category><![CDATA[pause]]></category>

		<guid isPermaLink="false">http://www.un-deprived.com/?p=244</guid>
		<description><![CDATA[…and controls to pause and play the time line. I’ve been using this script quite a bit, and I think it’s time to jog it down somewhere. A few things to keep in mind when using this script: Try not to use this script on the main/root time line. If you have movie clips within [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p>…and controls to pause and play the time line.</p>
<p><a href="http://www.un-deprived.com/wp-content/uploads/2009/08/thumb.jpg" rel="lightbox[244]" title="thumb"><img class="alignnone size-medium wp-image-246" title="thumb" src="http://www.un-deprived.com/wp-content/uploads/2009/08/thumb-301x125.jpg" alt="thumb" width="301" height="125" /></a></p>
<p>I’ve been using this script quite a bit, and I think it’s time to jog it down somewhere. A few things to keep in mind when using this script:<span id="more-244"></span></p>
<ol>
<li>Try not to use this script on the main/root time line. If you have movie clips within the main timeline, when the timer is up, it speeds through the entire time line to the every end. Stop(); won’t do anything.</li>
<li>This script works well inside a movie clip, also works for movie clips within a movie clip. But try to minimize it to only one clip</li>
<li>The controls (Pause, Play) buttons work best in the main / root time line, doesn’t work too well if there are clips within a clip</li>
</ol>
<p>Just insert the following inside a <em>movie clip’s time line</em> where you want it to pauses for a few moments:</p>
<div class="wp_syntax">
<div class="code">
<pre class="actionscript" style="font-family:monospace;">	 <span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">var</span> startTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #000000; font-weight: bold;">var</span> pausedTime = <span style="color: #cc66cc;">0</span>;
    <span style="color: #808080; font-style: italic;">//countTo = number of seconds.</span>
    <span style="color: #000000; font-weight: bold;">var</span> countTo:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;">10</span>;
    <span style="color: #000000; font-weight: bold;">var</span> ref:<span style="color: #0066CC;">MovieClip</span> = <span style="color: #0066CC;">this</span>;
&nbsp;
    <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">onEnterFrame</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Void</span> <span style="color: #66cc66;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>paused<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">var</span> elapsedTime:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>-ref.<span style="color: #006600;">startTime</span>-pausedTime;
            <span style="color: #000000; font-weight: bold;">var</span> count:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">ceil</span><span style="color: #66cc66;">&#40;</span>countTo-<span style="color: #66cc66;">&#40;</span>elapsedTime<span style="color: #66cc66;">*</span><span style="color: #cc66cc;">0.001</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>count<span style="color: #66cc66;">&amp;</span>lt;<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
                <span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">gotoAndPlay</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">nextFrame</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span></pre>
</div>
</div>
<p>In addition if you want to have Pause / Play buttons, insert the following codes after the above codes:</p>
<div class="wp_syntax">
<div class="code">
<pre class="actionscript" style="font-family:monospace;">	<span style="color: #0066CC;">_root</span>.<span style="color: #006600;">puz1</span>.<span style="color: #0066CC;">onRelease</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span>paused<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          pauseTime = <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
          paused=<span style="color: #000000; font-weight: bold;">true</span>;
          <span style="color: #0066CC;">_root</span>.<span style="color: #006600;">puz1</span>.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #0066CC;">_root</span>.<span style="color: #006600;">play1</span>.<span style="color: #0066CC;">onRelease</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
       <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>paused<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
          pausedTime += <span style="color: #0066CC;">getTimer</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - pauseTime;
          paused=<span style="color: #000000; font-weight: bold;">false</span>;
          <span style="color: #0066CC;">_root</span>.<span style="color: #006600;">puz1</span>.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
       <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span></pre>
</div>
</div>
<p><a href="http://www.un-deprived.com/wp-content/uploads/2009/08/timeline.jpg" rel="lightbox[244]" title="timeline"><img class="alignnone size-medium wp-image-248" title="timeline" src="http://www.un-deprived.com/wp-content/uploads/2009/08/timeline-151x125.jpg" alt="timeline" width="151" height="125" /></a><!-- PHP 5.x --></p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.un-deprived.com/2009/others/using-actionscript-2-0-to-pause-frames/feed/</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>
