<?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: How to Pause a Timeline (AS3)</title>
	<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Mon, 15 Mar 2010 00:23:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Richard Elmes</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-437552</link>
		<pubDate>Sat, 30 Jan 2010 14:39:51 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-437552</guid>
					<description>Hey thanks fr this. I am a newby to AS3 and fnd it difficult. I am planning to redesign my website and add in some flash so I am extremely grateful to you for this script.

Keep up the great work</description>
		<content:encoded><![CDATA[<p>Hey thanks fr this. I am a newby to AS3 and fnd it difficult. I am planning to redesign my website and add in some flash so I am extremely grateful to you for this script.</p>
<p>Keep up the great work
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400186</link>
		<pubDate>Wed, 24 Jun 2009 13:16:24 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400186</guid>
					<description>Mike W,

Glad to hear that!  The O'Reilly book is a compare/contrast reference to help developers migrate from ActionScript 2.0 to 3.0.  You can find a number of excerpts on the Adobe site at this URL:

&lt;a href=&quot;http://www.adobe.com/devnet/actionscript/articles/as3_quick_ref.html&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;
http://www.adobe.com/devnet/actionscript/articles/as3_quick_ref.html&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Mike W,</p>
<p>Glad to hear that!  The O&#8217;Reilly book is a compare/contrast reference to help developers migrate from ActionScript 2.0 to 3.0.  You can find a number of excerpts on the Adobe site at this URL:</p>
<p><a href="http://www.adobe.com/devnet/actionscript/articles/as3_quick_ref.html" target="_blank" rel="nofollow"><br />
<a href='http://www.adobe.com/devnet/actionscript/articles/as3_quick_ref.html' rel='nofollow'>http://www.adobe.com/devnet/actionscript/articles/as3_quick_ref.html</a></a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mike W</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400130</link>
		<pubDate>Wed, 24 Jun 2009 05:04:27 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400130</guid>
					<description>Good Morning David - thanks for the prompt and perfect assistance. Its exactly what I need and I can see where my attempts were coming short. I will be investing in your collaborative publication - if its anything like your online tuts, its sure to be most helpful. Thanks again. Mike</description>
		<content:encoded><![CDATA[<p>Good Morning David - thanks for the prompt and perfect assistance. Its exactly what I need and I can see where my attempts were coming short. I will be investing in your collaborative publication - if its anything like your online tuts, its sure to be most helpful. Thanks again. Mike
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400027</link>
		<pubDate>Tue, 23 Jun 2009 14:51:39 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400027</guid>
					<description>&lt;strong&gt;To Shaughn ...&lt;/strong&gt;
&lt;blockquote&gt;when the pedestrain presses the button, 2 seconds [later, the car] ... will stop at the a specific frame ... The car will only stop right behind the crosswalk and if its already in the crosswalk or after it, it will continue moving&lt;/blockquote&gt;

You wrote back in March, so I apologize for the delayed reply, here.  I realize you may have already moved on.  Your description indicates at least one &quot;if&quot; scenario, which means the pause script won't be enough, on its own, to handle what you're after.  I could see using an &lt;code&gt;if&lt;/code&gt; statement to check the vertical position of the pedestrian movie clip (assuming it's a movie clip), but that would only work of the coordinates of the pedestrian clip change over time.  If your pedestrian's movement happens &lt;em&gt;inside&lt;/em&gt; this pedestrian clip &amp;#8212; which it would if you're using timeline animation (that is, a tween) in that clip &amp;#8212; then you'd have to use some other means of indicating whether or not the pedestrian is present (or &lt;em&gt;where&lt;/em&gt; it is present).

Whatever your means, you could add an &lt;code&gt;if&lt;/code&gt; statement just before the operative line of code (the &lt;code&gt;play()&lt;/code&gt; method):

&lt;pre&gt;&lt;code&gt;stop();

var timer:Timer = new Timer(2000, 1);
timer.addEventListener(
  TimerEvent.TIMER,
  function(evt:TimerEvent):void {
    if (pedestrianClip.y &lt; 100) {
      play();
    }
  }
);
timer.start();&lt;/code&gt;&lt;/pre&gt;

In the above revision, the timeline in which this code appears would only continue playing if a movie clip with the instance name &lt;code&gt;pedestrianClip&lt;/code&gt; happens to be positioned lower than 100 pixels from its parent's registration point.

&lt;strong&gt;To Wayne ...&lt;/strong&gt;

&lt;blockquote&gt;I want to set the interval for the pause and learned that I need to use a timer which is fine.&lt;/blockquote&gt;

There are other approaches (&lt;em&gt;e.g.&lt;/em&gt;, an &lt;code&gt;enterFrame&lt;/code&gt; loop that checks against an incrementing number), but a timer is probably the least hassle.

&lt;blockquote&gt;I simply want the tween to stop and wait for a specified length of time and then continue on but I am unable to figure out how to tell AS3 to do nothing. I thought I had it once and had the timer all set but as soon as I entered the second leg of the journey (movieclip_mc.continueTo(x, d)), the pause no longer functioned.&lt;/blockquote&gt;

The trick isn't so much to instruct AS3 to do nothing, but rather, to &lt;em&gt;hold off&lt;/em&gt;, for the desired length of time, on instructing it to do &lt;em&gt;anything&lt;/em&gt;.  You mention a &lt;code&gt;continueTo()&lt;/code&gt; method, but that isn't part of the &lt;code&gt;MovieClip&lt;/code&gt; class, so I'm assuming you've got some other code in play here (maybe one of the numerous popular tweening APIs?).  If you're tweening your movie clips with code, then the pause script I've suggested may not do anything.  At rock bottom, it simply stops the current timeline (thus pausing any tweens, by happenstance, in that timeline), waits, then plays that timeline again.

It may help you sort out the code a bit if you see the same thing presented with a named function, rather than a function declaration inside the &lt;code&gt;addEventListener()&lt;/code&gt; method.  Check it out:

&lt;pre&gt;&lt;code&gt;stop();

var timer:Timer = new Timer(2000, 1);
timer.addEventListener(TimerEvent.TIMER, resume);
timer.start();

function resume(evt:TimerEvent):void {
  play();
);&lt;/code&gt;&lt;/pre&gt;

All the mechanics are the same ... it's just that the functional part, the part that restarts the timeline, is now declared as a named function, and the name of the function is now used as the second parameter in the &lt;code&gt;addEventListener()&lt;/code&gt; method.  In this arrangement, the code looks a bit less cluttered.  I don't know if that helps you get a better grasp on the &lt;code&gt;Timer&lt;/code&gt; class, but I hope so!  Be aware that you can put whatever you like inside the to-be-triggered function (here named &lt;code&gt;resume&lt;/code&gt;).  In this case, there's only a single line of code (&lt;code&gt;play()&lt;/code&gt;), but you could add a second line after that (say, a &lt;code&gt;trace()&lt;/code&gt; statement, so you can send messages to the Output panel, which helps with troubleshooting), or as many additional lines as you like.

If the pausing doesn't do what you expect during the second leg of the journey, it may be that you forgot to re-invoke the &lt;code&gt;time.start()&lt;/code&gt; line?  In the constructor (&lt;code&gt;new Timer(2000, 1)&lt;/code&gt;) the second parameter determines that the timer only fires once.  If you want it to fire more often, change that 1 to a 0 (repeats forever), 2 (repeats twice), and so on.  In this particular case, for pausing a timeline, a value of 1 likely makes the most sense, because after the &lt;code&gt;stop()&lt;/code&gt; method, you only want to resume the timeline once.  When you want to pause the timeline again later, you have to again provide a &lt;code&gt;stop()&lt;/code&gt; method (in some other frame, down the line), and then again start the timer (&lt;code&gt;time.start()&lt;/code&gt;).

&lt;strong&gt;To Mike W ...&lt;/strong&gt;

&lt;blockquote&gt;I want to create a single .AS file containg a &quot;Pause The Timeline&quot; function that I can call from various .fla's ... Is this possible?&lt;/blockquote&gt;

You bet!  In fact, I included a scenario just like this in &lt;a href=&quot;http://tinyurl.com/dpsAS3QuickReferenceGuide&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;&lt;em&gt;ActionScript 3.0 Quick Reference Guide&lt;/em&gt;&lt;/a&gt; (O'Reilly).  If you visit the book's page on the O'Reilly site ...

&lt;a href=&quot;http://oreilly.com/catalog/9780596517359/&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;http://oreilly.com/catalog/9780596517359/&lt;/a&gt;

... you'll see an Examples link beneath the image of the book cover.  Use that to download AS3QRG_samples.zip (approx 53MB), and you'll find a working example in the Chapter 6 ZIP file.  (Look for the CompanyTemplate example.)</description>
		<content:encoded><![CDATA[<p><strong>To Shaughn &#8230;</strong></p>
<blockquote><p>when the pedestrain presses the button, 2 seconds [later, the car] &#8230; will stop at the a specific frame &#8230; The car will only stop right behind the crosswalk and if its already in the crosswalk or after it, it will continue moving</p></blockquote>
<p>You wrote back in March, so I apologize for the delayed reply, here.  I realize you may have already moved on.  Your description indicates at least one &#8220;if&#8221; scenario, which means the pause script won&#8217;t be enough, on its own, to handle what you&#8217;re after.  I could see using an <code>if</code> statement to check the vertical position of the pedestrian movie clip (assuming it&#8217;s a movie clip), but that would only work of the coordinates of the pedestrian clip change over time.  If your pedestrian&#8217;s movement happens <em>inside</em> this pedestrian clip &mdash; which it would if you&#8217;re using timeline animation (that is, a tween) in that clip &mdash; then you&#8217;d have to use some other means of indicating whether or not the pedestrian is present (or <em>where</em> it is present).</p>
<p>Whatever your means, you could add an <code>if</code> statement just before the operative line of code (the <code>play()</code> method):</p>
<pre><code>stop();

var timer:Timer = new Timer(2000, 1);
timer.addEventListener(
  TimerEvent.TIMER,
  function(evt:TimerEvent):void {
    if (pedestrianClip.y < 100) {
      play();
    }
  }
);
timer.start();</code></pre>
<p>In the above revision, the timeline in which this code appears would only continue playing if a movie clip with the instance name <code>pedestrianClip</code> happens to be positioned lower than 100 pixels from its parent&#8217;s registration point.</p>
<p><strong>To Wayne &#8230;</strong></p>
<blockquote><p>I want to set the interval for the pause and learned that I need to use a timer which is fine.</p></blockquote>
<p>There are other approaches (<em>e.g.</em>, an <code>enterFrame</code> loop that checks against an incrementing number), but a timer is probably the least hassle.</p>
<blockquote><p>I simply want the tween to stop and wait for a specified length of time and then continue on but I am unable to figure out how to tell AS3 to do nothing. I thought I had it once and had the timer all set but as soon as I entered the second leg of the journey (movieclip_mc.continueTo(x, d)), the pause no longer functioned.</p></blockquote>
<p>The trick isn&#8217;t so much to instruct AS3 to do nothing, but rather, to <em>hold off</em>, for the desired length of time, on instructing it to do <em>anything</em>.  You mention a <code>continueTo()</code> method, but that isn&#8217;t part of the <code>MovieClip</code> class, so I&#8217;m assuming you&#8217;ve got some other code in play here (maybe one of the numerous popular tweening APIs?).  If you&#8217;re tweening your movie clips with code, then the pause script I&#8217;ve suggested may not do anything.  At rock bottom, it simply stops the current timeline (thus pausing any tweens, by happenstance, in that timeline), waits, then plays that timeline again.</p>
<p>It may help you sort out the code a bit if you see the same thing presented with a named function, rather than a function declaration inside the <code>addEventListener()</code> method.  Check it out:</p>
<pre><code>stop();

var timer:Timer = new Timer(2000, 1);
timer.addEventListener(TimerEvent.TIMER, resume);
timer.start();

function resume(evt:TimerEvent):void {
  play();
);</code></pre>
<p>All the mechanics are the same &#8230; it&#8217;s just that the functional part, the part that restarts the timeline, is now declared as a named function, and the name of the function is now used as the second parameter in the <code>addEventListener()</code> method.  In this arrangement, the code looks a bit less cluttered.  I don&#8217;t know if that helps you get a better grasp on the <code>Timer</code> class, but I hope so!  Be aware that you can put whatever you like inside the to-be-triggered function (here named <code>resume</code>).  In this case, there&#8217;s only a single line of code (<code>play()</code>), but you could add a second line after that (say, a <code>trace()</code> statement, so you can send messages to the Output panel, which helps with troubleshooting), or as many additional lines as you like.</p>
<p>If the pausing doesn&#8217;t do what you expect during the second leg of the journey, it may be that you forgot to re-invoke the <code>time.start()</code> line?  In the constructor (<code>new Timer(2000, 1)</code>) the second parameter determines that the timer only fires once.  If you want it to fire more often, change that 1 to a 0 (repeats forever), 2 (repeats twice), and so on.  In this particular case, for pausing a timeline, a value of 1 likely makes the most sense, because after the <code>stop()</code> method, you only want to resume the timeline once.  When you want to pause the timeline again later, you have to again provide a <code>stop()</code> method (in some other frame, down the line), and then again start the timer (<code>time.start()</code>).</p>
<p><strong>To Mike W &#8230;</strong></p>
<blockquote><p>I want to create a single .AS file containg a &#8220;Pause The Timeline&#8221; function that I can call from various .fla&#8217;s &#8230; Is this possible?</p></blockquote>
<p>You bet!  In fact, I included a scenario just like this in <a href="http://tinyurl.com/dpsAS3QuickReferenceGuide" target="_blank" rel="nofollow"><em>ActionScript 3.0 Quick Reference Guide</em></a> (O&#8217;Reilly).  If you visit the book&#8217;s page on the O&#8217;Reilly site &#8230;</p>
<p><a href="http://oreilly.com/catalog/9780596517359/" target="_blank" rel="nofollow"><a href='http://oreilly.com/catalog/9780596517359/' rel='nofollow'>http://oreilly.com/catalog/9780596517359/</a></a></p>
<p>&#8230; you&#8217;ll see an Examples link beneath the image of the book cover.  Use that to download AS3QRG_samples.zip (approx 53MB), and you&#8217;ll find a working example in the Chapter 6 ZIP file.  (Look for the CompanyTemplate example.)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Mike W</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400002</link>
		<pubDate>Tue, 23 Jun 2009 10:49:08 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-400002</guid>
					<description>I'm new to ActionScript 3 and must also congratulate you on a clear, concise and easily readable and understandable tutorial here. Going back to your original article on pausing the timeline - I can achieve this without problem and I can also put the same 'amdended' code in subsequent keframes to pause the timeline. I'm struggling though to create a class for this function so that I can call it in a number of keyframes in a number of different MC's all pertaining to a single project. In other words (and excuse my lack of correct terminology here) I want to create a single .AS file containg a &quot;Pause The Timeline&quot; function that I can call from various .fla's in a format like:
timelinePause(2000);
where 2000 is the number of milliseconds to wait before continuing to play the timeline. Is this possible? Is there sample AS3 code available? Any help or a pointer in the right direction would be greatly appreciated. Thanks.</description>
		<content:encoded><![CDATA[<p>I&#8217;m new to ActionScript 3 and must also congratulate you on a clear, concise and easily readable and understandable tutorial here. Going back to your original article on pausing the timeline - I can achieve this without problem and I can also put the same &#8216;amdended&#8217; code in subsequent keframes to pause the timeline. I&#8217;m struggling though to create a class for this function so that I can call it in a number of keyframes in a number of different MC&#8217;s all pertaining to a single project. In other words (and excuse my lack of correct terminology here) I want to create a single .AS file containg a &#8220;Pause The Timeline&#8221; function that I can call from various .fla&#8217;s in a format like:<br />
timelinePause(2000);<br />
where 2000 is the number of milliseconds to wait before continuing to play the timeline. Is this possible? Is there sample AS3 code available? Any help or a pointer in the right direction would be greatly appreciated. Thanks.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Wayne</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-399642</link>
		<pubDate>Sun, 21 Jun 2009 07:26:14 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-399642</guid>
					<description>I am trying to use the timer class discussed here and cannot get a firm understanding. Here is what I am trying to do:

I made a marquee, similar to the html marquee, the text is a long string broken up into segments. I have a tween to move the marquee from beginning to end and an array containing stop points at which I want the marquee to pause, wait, and then continue. I want to set the interval for the pause and learned that I need to use a timer which is fine. I understand how to set up the timer and send it to a function... it is inside the function that I get confused... I simply want the tween to stop and wait for a specified length of time and then continue on but I am unable to figure out how to tell AS3 to do nothing. I thought I had it once and had the timer all set but as soon as I entered the second leg of the journey (movieclip_mc.continueTo(x, d)), the pause no longer functioned. It was as if ActionScript ignored the pause function totally and I am not understanding how this is possible and how to prevent it. I have been searching for this for several days now beating my head against the wall at every step. Any assistance would be appreciated.</description>
		<content:encoded><![CDATA[<p>I am trying to use the timer class discussed here and cannot get a firm understanding. Here is what I am trying to do:</p>
<p>I made a marquee, similar to the html marquee, the text is a long string broken up into segments. I have a tween to move the marquee from beginning to end and an array containing stop points at which I want the marquee to pause, wait, and then continue. I want to set the interval for the pause and learned that I need to use a timer which is fine. I understand how to set up the timer and send it to a function&#8230; it is inside the function that I get confused&#8230; I simply want the tween to stop and wait for a specified length of time and then continue on but I am unable to figure out how to tell AS3 to do nothing. I thought I had it once and had the timer all set but as soon as I entered the second leg of the journey (movieclip_mc.continueTo(x, d)), the pause no longer functioned. It was as if ActionScript ignored the pause function totally and I am not understanding how this is possible and how to prevent it. I have been searching for this for several days now beating my head against the wall at every step. Any assistance would be appreciated.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Shaughn</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-357744</link>
		<pubDate>Tue, 03 Mar 2009 20:00:46 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-357744</guid>
					<description>Hi David, I am trying to make a Pedestrian crosswalk for a road. So when the pedestrain presses the button, 2 seconds after the car(which is a movie clip) will stop at the a specific frame, or specific place right behind the crosswalk or intersection. The car will only stop right behind the crosswalk and if its already in the crosswalk or after it, it will continue moving.
Thanks david</description>
		<content:encoded><![CDATA[<p>Hi David, I am trying to make a Pedestrian crosswalk for a road. So when the pedestrain presses the button, 2 seconds after the car(which is a movie clip) will stop at the a specific frame, or specific place right behind the crosswalk or intersection. The car will only stop right behind the crosswalk and if its already in the crosswalk or after it, it will continue moving.<br />
Thanks david
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-349261</link>
		<pubDate>Fri, 13 Feb 2009 01:19:29 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-349261</guid>
					<description>&lt;strong&gt;To Jerry ...&lt;/strong&gt;

Glad to hear this approach works for you!  I wonder you accidentally mistyped something in the case of those other approaches?  I'd be curious to see what they were.  Flash usually gives you half a dozen ways to solve any given problem, which is sometimes a blessing and sometimes a curse.  ;)

&lt;strong&gt;To Chris ...&lt;/strong&gt;

Keep your chin up!  It was overwhelming to me at first too, but so was AS2.  With practice, it starts to gel &amp;#8212; and for me, AS3 ended up making more sense, all told, than AS2.

&lt;strong&gt;To Daniel ...&lt;/strong&gt;

&lt;blockquote&gt;I wanted to create a loop to get all the movieclips on the root and stop them.&lt;/blockquote&gt;

Cool.  It's not too hard, as long as you're doing in the confines of a particular scope, such as the main timeline.

&lt;blockquote&gt;I know how to do this in AS2, but I had no luck converting it to AS3.&lt;/blockquote&gt;

The principle is the same, actually, but you go about it a different way.  In AS2, you can use a &lt;code&gt;for..in&lt;/code&gt; loop, test to see if the current object is a movie clip, then invoke the &lt;code&gt;MovieClip.stop()&lt;/code&gt; method on it, like this:

&lt;pre&gt;&lt;code&gt;for (var clip:String in this) {
  if (typeof(this[clip]) == &quot;movieclip&quot;) {
    this[clip].stop();
  }
}&lt;/code&gt;&lt;/pre&gt;

That will stop all movie clips in the scope of the &lt;code&gt;for..in&lt;/code&gt; loop, no matter what their instance names are (or even if they don't have instance names).

In AS3, those movie clips belong to a display list, which means you can access them directly by instance name if you know it.  If you &lt;em&gt;don't&lt;/em&gt; know it, or don't care to know, you can simply loop through the display list of the current scope and pull off the same trick.  Instead of a &lt;code&gt;for..in&lt;/code&gt; loop, just use a &lt;code&gt;for&lt;/code&gt; loop, like this:

&lt;pre&gt;&lt;code&gt;for (var i:int = 0; i &lt; this.numChildren; i++) {
  if (this.getChildAt(i) is MovieClip) {
    MovieClip(this.getChildAt(i)).stop();
  }
}&lt;/code&gt;&lt;/pre&gt;

Here, the &lt;code&gt;typeof&lt;/code&gt; operator is replaced by &lt;code&gt;is&lt;/code&gt;, which compares against an actual class name (&lt;code&gt;MovieClip&lt;/code&gt;) rather than a string representative.  If the condition is true (it's a movie clip), cast the expression &lt;code&gt;this.getChildAt()&lt;/code&gt; as a &lt;code&gt;MovieClip&lt;/code&gt; &amp;#8212; otherwise Flash thinks it's a &lt;code&gt;DisplayObject&lt;/code&gt; (which it is, but it's also a &lt;code&gt;MovieClip&lt;/code&gt;; and &lt;code&gt;DisplayObject&lt;/code&gt;s don't have a &lt;code&gt;stop()&lt;/code&gt; method &amp;#8212; and stop the clip.</description>
		<content:encoded><![CDATA[<p><strong>To Jerry &#8230;</strong></p>
<p>Glad to hear this approach works for you!  I wonder you accidentally mistyped something in the case of those other approaches?  I&#8217;d be curious to see what they were.  Flash usually gives you half a dozen ways to solve any given problem, which is sometimes a blessing and sometimes a curse.  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>To Chris &#8230;</strong></p>
<p>Keep your chin up!  It was overwhelming to me at first too, but so was AS2.  With practice, it starts to gel &mdash; and for me, AS3 ended up making more sense, all told, than AS2.</p>
<p><strong>To Daniel &#8230;</strong></p>
<blockquote><p>I wanted to create a loop to get all the movieclips on the root and stop them.</p></blockquote>
<p>Cool.  It&#8217;s not too hard, as long as you&#8217;re doing in the confines of a particular scope, such as the main timeline.</p>
<blockquote><p>I know how to do this in AS2, but I had no luck converting it to AS3.</p></blockquote>
<p>The principle is the same, actually, but you go about it a different way.  In AS2, you can use a <code>for..in</code> loop, test to see if the current object is a movie clip, then invoke the <code>MovieClip.stop()</code> method on it, like this:</p>
<pre><code>for (var clip:String in this) {
  if (typeof(this[clip]) == "movieclip") {
    this[clip].stop();
  }
}</code></pre>
<p>That will stop all movie clips in the scope of the <code>for..in</code> loop, no matter what their instance names are (or even if they don&#8217;t have instance names).</p>
<p>In AS3, those movie clips belong to a display list, which means you can access them directly by instance name if you know it.  If you <em>don&#8217;t</em> know it, or don&#8217;t care to know, you can simply loop through the display list of the current scope and pull off the same trick.  Instead of a <code>for..in</code> loop, just use a <code>for</code> loop, like this:</p>
<pre><code>for (var i:int = 0; i < this.numChildren; i++) {
  if (this.getChildAt(i) is MovieClip) {
    MovieClip(this.getChildAt(i)).stop();
  }
}</code></pre>
<p>Here, the <code>typeof</code> operator is replaced by <code>is</code>, which compares against an actual class name (<code>MovieClip</code>) rather than a string representative.  If the condition is true (it&#8217;s a movie clip), cast the expression <code>this.getChildAt()</code> as a <code>MovieClip</code> &mdash; otherwise Flash thinks it&#8217;s a <code>DisplayObject</code> (which it is, but it&#8217;s also a <code>MovieClip</code>; and <code>DisplayObject</code>s don&#8217;t have a <code>stop()</code> method &mdash; and stop the clip.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brad</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-348744</link>
		<pubDate>Wed, 11 Feb 2009 23:16:35 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-348744</guid>
					<description>My question is simple. I haven't used flash in a while.. the last version I used you could use the actionscript menu to enter a stop command to stop the movie. I know in CS4 I can type the stop command, but the question is where did they move it to in the menu. I think it was version 8 that had basic command right at the top in the actions window. Don't see those basic &quot;control&quot; commands.. so where did they move them to. How do you enter these simple command without typing them. Stop, play etc. Just can't find them in the menu structure.

Thanks</description>
		<content:encoded><![CDATA[<p>My question is simple. I haven&#8217;t used flash in a while.. the last version I used you could use the actionscript menu to enter a stop command to stop the movie. I know in CS4 I can type the stop command, but the question is where did they move it to in the menu. I think it was version 8 that had basic command right at the top in the actions window. Don&#8217;t see those basic &#8220;control&#8221; commands.. so where did they move them to. How do you enter these simple command without typing them. Stop, play etc. Just can&#8217;t find them in the menu structure.</p>
<p>Thanks
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Daniel</title>
		<link>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-348115</link>
		<pubDate>Mon, 09 Feb 2009 11:26:07 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/how-to-pause-timeline-as3#comment-348115</guid>
					<description>Hi David,

Your articles really help me a lot, but I'm still in trouble with this stop-other-movieclips thing.
It's a little bit similar with Shelly Colvin question, except that this time I have a bigger presentation with a dozen of nested movieclips.
I didn't want to write every instance name inside de pauseTimelines function, instead, I wanted to create a loop to get all the movieclips on the root and stop them.

I know how to do this in AS2, but I had no luck converting it to AS3.

(Sorry for my english, I'm brazillian and don't write that often).</description>
		<content:encoded><![CDATA[<p>Hi David,</p>
<p>Your articles really help me a lot, but I&#8217;m still in trouble with this stop-other-movieclips thing.<br />
It&#8217;s a little bit similar with Shelly Colvin question, except that this time I have a bigger presentation with a dozen of nested movieclips.<br />
I didn&#8217;t want to write every instance name inside de pauseTimelines function, instead, I wanted to create a loop to get all the movieclips on the root and stop them.</p>
<p>I know how to do this in AS2, but I had no luck converting it to AS3.</p>
<p>(Sorry for my english, I&#8217;m brazillian and don&#8217;t write that often).
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
