<?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: Trust Me, AS3, It&#8217;s a MovieClip</title>
	<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Wed, 19 Nov 2008 04:27:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Alex Wilson</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-269954</link>
		<pubDate>Fri, 12 Sep 2008 21:07:08 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-269954</guid>
					<description>Hi David...I've been pulling out what little hair I have left trying to solve a little problem I'm having communicating between parents and children with AS3.  Thought you may be able to help.  Lets say that you have a master swf. that you load another .swf into via addChild and the URLRequest ect.. If I have a button in the loaded .swf and wanted to communicate back to the parent .swf I would do (and have done with great success) what you described above (MovieClip(this.parent).stop():).  My question is....what if I want to do the opposite.   What if you have a button on the master .swf and want to communicate up to the child swf?  I basically just want to stop the loaded .swf from playing with a button on the main timeline.  (MovieClip(??????).stop)   I've tried everything I can think of and nothing seem to work?  HELP</description>
		<content:encoded><![CDATA[<p>Hi David&#8230;I&#8217;ve been pulling out what little hair I have left trying to solve a little problem I&#8217;m having communicating between parents and children with AS3.  Thought you may be able to help.  Lets say that you have a master swf. that you load another .swf into via addChild and the URLRequest ect.. If I have a button in the loaded .swf and wanted to communicate back to the parent .swf I would do (and have done with great success) what you described above (MovieClip(this.parent).stop():).  My question is&#8230;.what if I want to do the opposite.   What if you have a button on the master .swf and want to communicate up to the child swf?  I basically just want to stop the loaded .swf from playing with a button on the main timeline.  (MovieClip(??????).stop)   I&#8217;ve tried everything I can think of and nothing seem to work?  HELP
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-183408</link>
		<pubDate>Thu, 15 May 2008 04:02:36 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-183408</guid>
					<description>Alex,

Thanks for picking up &lt;em&gt;Foundation&lt;/em&gt;!  I hope you enjoy it!  :)  Tom and I tried to make it fun as well as informative.

As for your non-FLV scrubber, it's definitely a good idea and would make a useful tutorial.  Hearing it as you've described it, two things come to my mind:  a) you'd like to scrub a loaded SWF/movie clip and/or b) you'd like to scrub a series of stills, which are being displayed on a &lt;code&gt;Timer&lt;/code&gt;-run basis.  To accomplish that first one, you could look at the &lt;code&gt;MovieClip.currentFrame&lt;/code&gt; and &lt;code&gt;MovieClip.totalFrames&lt;/code&gt; properties &amp;#8212; those would be comparable to the &lt;code&gt;time&lt;/code&gt; and &lt;code&gt;duration&lt;/code&gt; properties used in cahoots with FLVs in the &lt;a href=&quot;http://www.quip.net/blog/2007/flash/actionscript-20/how-to-build-flv-progress-bar-part2&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;draggable progress bar (AS2) article&lt;/a&gt; elsewhere on this blog.  If you construct knob and track movie clips as described in that other article, the following &amp;#8212; just a rough sketch &amp;#8212; will allow the knob/track combo to scrub the frames of a movie clip with the instance name &lt;code&gt;mc&lt;/code&gt;:

&lt;pre&gt;&lt;code&gt;mc.stop();

var ratio:Number = track.width / mc.totalFrames;
var vertical:Number;

knob.addEventListener(
  MouseEvent.MOUSE_DOWN,
  mouseDownHandler
);
knob.addEventListener(
  MouseEvent.MOUSE_UP,
  mouseUpHandler
);

function mouseDownHandler(evt:MouseEvent):void {
  vertical = track.y + (track.height / 2);
  knob.startDrag(
    true,
    new Rectangle(
      track.x,
      vertical,
      track.width,
      0
    )
  );
  knob.addEventListener(
    MouseEvent.MOUSE_MOVE,
    mouseMoveHandler
  );
}

function mouseUpHandler(evt:MouseEvent):void {
  knob.stopDrag();
  knob.removeEventListener(
    MouseEvent.MOUSE_MOVE,
    mouseMoveHandler
  );
}

function mouseMoveHandler(evt:MouseEvent):void {
  mc.gotoAndStop(
    Math.floor(
      (knob.x - track.x) / ratio
    )
  );
}&lt;/code&gt;&lt;/pre&gt;

Compare that against the AS2 code shown for the video scrubber, and you'll see considerable (almost complete) overlap &amp;#8212; though this version is only a scrubber, not a progress indicator.  A progress indicator would require an update of the knob clip on, say, an &lt;code&gt;ENTER_FRAME&lt;/code&gt; handler.

The trouble with scrubbing SWFs like this is that all it does (at least, as I've shown it) is scrub the SWF's (or movie clip's) main timeline.  Nested timelines &amp;#8212; or, more confoundingly, interior animation generated by ActionScript &amp;#8212; simply isn't something a scrubbing mechanism can accommodate.

If you're talking about the other approach (choice B above), then you could theoretically store your image/still references in an array and &quot;scrub&quot; through the array.  In which case your &lt;code&gt;currentFrame&lt;/code&gt;/&lt;code&gt;totalFrames&lt;/code&gt; equivalents would be a variable for counting (often &lt;code&gt;i&lt;/code&gt;, like you would use in a &lt;code&gt;for&lt;/code&gt; loop) and the &lt;code&gt;Array.length&lt;/code&gt; property.  To make the &quot;scrubbing&quot; actually &lt;em&gt;do&lt;/em&gt; something ... well, that would depend entirely on how the slideshow was programmed. It could definitely get complicated pretty quickly, especially if the scrubber needed to halt and resume a timer.

I do keep a lengthy to-do list for this blog, and your idea(s) are definitely worth writing about, so I've added them to the list.  The only thing iffy about the whole kaboodle is that lately I'm so incredibly behind on this blog!  I'm working on two books at the moment, and that has taken its toll on my Adobe forum presence and this blog.</description>
		<content:encoded><![CDATA[<p>Alex,</p>
<p>Thanks for picking up <em>Foundation</em>!  I hope you enjoy it!  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Tom and I tried to make it fun as well as informative.</p>
<p>As for your non-FLV scrubber, it&#8217;s definitely a good idea and would make a useful tutorial.  Hearing it as you&#8217;ve described it, two things come to my mind:  a) you&#8217;d like to scrub a loaded SWF/movie clip and/or b) you&#8217;d like to scrub a series of stills, which are being displayed on a <code>Timer</code>-run basis.  To accomplish that first one, you could look at the <code>MovieClip.currentFrame</code> and <code>MovieClip.totalFrames</code> properties &mdash; those would be comparable to the <code>time</code> and <code>duration</code> properties used in cahoots with FLVs in the <a href="http://www.quip.net/blog/2007/flash/actionscript-20/how-to-build-flv-progress-bar-part2" target="_blank" rel="nofollow">draggable progress bar (AS2) article</a> elsewhere on this blog.  If you construct knob and track movie clips as described in that other article, the following &mdash; just a rough sketch &mdash; will allow the knob/track combo to scrub the frames of a movie clip with the instance name <code>mc</code>:</p>
<pre><code>mc.stop();

var ratio:Number = track.width / mc.totalFrames;
var vertical:Number;

knob.addEventListener(
  MouseEvent.MOUSE_DOWN,
  mouseDownHandler
);
knob.addEventListener(
  MouseEvent.MOUSE_UP,
  mouseUpHandler
);

function mouseDownHandler(evt:MouseEvent):void {
  vertical = track.y + (track.height / 2);
  knob.startDrag(
    true,
    new Rectangle(
      track.x,
      vertical,
      track.width,
      0
    )
  );
  knob.addEventListener(
    MouseEvent.MOUSE_MOVE,
    mouseMoveHandler
  );
}

function mouseUpHandler(evt:MouseEvent):void {
  knob.stopDrag();
  knob.removeEventListener(
    MouseEvent.MOUSE_MOVE,
    mouseMoveHandler
  );
}

function mouseMoveHandler(evt:MouseEvent):void {
  mc.gotoAndStop(
    Math.floor(
      (knob.x - track.x) / ratio
    )
  );
}</code></pre>
<p>Compare that against the AS2 code shown for the video scrubber, and you&#8217;ll see considerable (almost complete) overlap &mdash; though this version is only a scrubber, not a progress indicator.  A progress indicator would require an update of the knob clip on, say, an <code>ENTER_FRAME</code> handler.</p>
<p>The trouble with scrubbing SWFs like this is that all it does (at least, as I&#8217;ve shown it) is scrub the SWF&#8217;s (or movie clip&#8217;s) main timeline.  Nested timelines &mdash; or, more confoundingly, interior animation generated by ActionScript &mdash; simply isn&#8217;t something a scrubbing mechanism can accommodate.</p>
<p>If you&#8217;re talking about the other approach (choice B above), then you could theoretically store your image/still references in an array and &#8220;scrub&#8221; through the array.  In which case your <code>currentFrame</code>/<code>totalFrames</code> equivalents would be a variable for counting (often <code>i</code>, like you would use in a <code>for</code> loop) and the <code>Array.length</code> property.  To make the &#8220;scrubbing&#8221; actually <em>do</em> something &#8230; well, that would depend entirely on how the slideshow was programmed. It could definitely get complicated pretty quickly, especially if the scrubber needed to halt and resume a timer.</p>
<p>I do keep a lengthy to-do list for this blog, and your idea(s) are definitely worth writing about, so I&#8217;ve added them to the list.  The only thing iffy about the whole kaboodle is that lately I&#8217;m so incredibly behind on this blog!  I&#8217;m working on two books at the moment, and that has taken its toll on my Adobe forum presence and this blog.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Alex Wilson</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-173682</link>
		<pubDate>Thu, 01 May 2008 15:37:34 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-173682</guid>
					<description>Hi David...I really enjoy your blog..you have saved me on more then one occasion.  I'm just getting into AS3 and just bought your Foundation book. 

I have a question and it might be more then you are willing to get into.  I know this may not be the right topic to post this in but I thought of it because you mentioned things like the Timer class and and totalFrames early in the posting.  

I do a lot of audio slide show-type projects where I put down an edited piece of audio down in a layer then a series of photos down under that and create fades (usually all in the main timeline but sometimes I used nested movie clips) and that sort of thing.  I have looked all over the internet, in books and have asked everyone I know about how to make a scrubber bar that could show the progress of the slide show.  The viewer would be able to grab a button on the bar and slide it to go to different points in the slide show.  There are a lot of tutorials on the web about how to build a seek slider bar for .flv files but I can't find any on how to build one for regular flash content.

Like I said, this may be to complex an issue to give a quick answer so I understand if you don't want to deal with it but if you do have a AS3 solution or if you have posted anything similar an another entry or something let me know.  Thanks!</description>
		<content:encoded><![CDATA[<p>Hi David&#8230;I really enjoy your blog..you have saved me on more then one occasion.  I&#8217;m just getting into AS3 and just bought your Foundation book. </p>
<p>I have a question and it might be more then you are willing to get into.  I know this may not be the right topic to post this in but I thought of it because you mentioned things like the Timer class and and totalFrames early in the posting.  </p>
<p>I do a lot of audio slide show-type projects where I put down an edited piece of audio down in a layer then a series of photos down under that and create fades (usually all in the main timeline but sometimes I used nested movie clips) and that sort of thing.  I have looked all over the internet, in books and have asked everyone I know about how to make a scrubber bar that could show the progress of the slide show.  The viewer would be able to grab a button on the bar and slide it to go to different points in the slide show.  There are a lot of tutorials on the web about how to build a seek slider bar for .flv files but I can&#8217;t find any on how to build one for regular flash content.</p>
<p>Like I said, this may be to complex an issue to give a quick answer so I understand if you don&#8217;t want to deal with it but if you do have a AS3 solution or if you have posted anything similar an another entry or something let me know.  Thanks!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-138460</link>
		<pubDate>Sat, 23 Feb 2008 02:16:37 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-138460</guid>
					<description>alan,

For that, you could program a button in the subclip to instruct the main timeline to stop, while instructing the subclip's timeline to play.  Assuming a button instance name of &lt;code&gt;myButton&lt;/code&gt;:

&lt;pre&gt;&lt;code&gt;myButton.addEventListener(
  MouseEvent.MOUSE_UP,
  function(evt:MouseEvent):void {
    MovieClip(this.parent).stop();
    play()
  }
);&lt;/code&gt;&lt;/pre&gt;

Is that what you mean?</description>
		<content:encoded><![CDATA[<p>alan,</p>
<p>For that, you could program a button in the subclip to instruct the main timeline to stop, while instructing the subclip&#8217;s timeline to play.  Assuming a button instance name of <code>myButton</code>:</p>
<pre><code>myButton.addEventListener(
  MouseEvent.MOUSE_UP,
  function(evt:MouseEvent):void {
    MovieClip(this.parent).stop();
    play()
  }
);</code></pre>
<p>Is that what you mean?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: alan</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-132930</link>
		<pubDate>Tue, 12 Feb 2008 15:51:18 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-132930</guid>
					<description>Regarding the pausing action at the top, what if you want more interactivity and continue to play the main timeline whilst paused sub movies appear in the window? I need the user to be able to click on the sub clip whenever they like, (only then would i like the main timeline movie to stop) then once the submovie has played, the main shall resume exactly where it left off.
any ideas please???

Thanks</description>
		<content:encoded><![CDATA[<p>Regarding the pausing action at the top, what if you want more interactivity and continue to play the main timeline whilst paused sub movies appear in the window? I need the user to be able to click on the sub clip whenever they like, (only then would i like the main timeline movie to stop) then once the submovie has played, the main shall resume exactly where it left off.<br />
any ideas please???</p>
<p>Thanks
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-127116</link>
		<pubDate>Fri, 01 Feb 2008 15:11:11 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-127116</guid>
					<description>tunghoy,

Sounds good!  Flash usually provides numerous ways to reach a given goal.</description>
		<content:encoded><![CDATA[<p>tunghoy,</p>
<p>Sounds good!  Flash usually provides numerous ways to reach a given goal.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: tunghoy</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-126759</link>
		<pubDate>Thu, 31 Jan 2008 23:00:58 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-126759</guid>
					<description>OK, what I did was create Pause and Play buttons on a layer in the first MC, then copied and pasted the layer to the other MCs. Using your code for the video and code that I learned for the external sound, I got it working (copying and pasting the code to each MC, also) -- the buttons pause &amp;#38; play the timeline and the sound.

I suppose one day I'll try looping through an array of child MCs so I can have just 1 set of buttons on the main timeline. But that isn't today!

My next part of the project is a mute button. That shouldn't be too hard. I'll get the volume, set it to zero on one click, then set it back to where it was on the next click.</description>
		<content:encoded><![CDATA[<p>OK, what I did was create Pause and Play buttons on a layer in the first MC, then copied and pasted the layer to the other MCs. Using your code for the video and code that I learned for the external sound, I got it working (copying and pasting the code to each MC, also) &#8212; the buttons pause &amp; play the timeline and the sound.</p>
<p>I suppose one day I&#8217;ll try looping through an array of child MCs so I can have just 1 set of buttons on the main timeline. But that isn&#8217;t today!</p>
<p>My next part of the project is a mute button. That shouldn&#8217;t be too hard. I&#8217;ll get the volume, set it to zero on one click, then set it back to where it was on the next click.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-126671</link>
		<pubDate>Thu, 31 Jan 2008 18:10:43 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-126671</guid>
					<description>tunghoy,

Each of those child MCs has a timeline of its own.  For every timeline you want to stop, you have to invoke a &lt;code&gt;MovieClip.stop()&lt;/code&gt; on it.  The simple pause mechanism on this blog (AS2 and AS3 versions) only pauses the timeline it's in, so to pause the main timeline, you use the code as is; to pause the main timeline and a bunch of movie clips ... well, you'd have to loop through the properties of the main timeline in AS2 (use a &lt;code&gt;for..in&lt;/code&gt; loop), then, using &lt;code&gt;instanceof&lt;/code&gt; to weed out the movie clips, invoke &lt;code&gt;stop()&lt;/code&gt; on the others.  In AS3, you could use a similar approach by checking the children of the display list.

It gets even more complicated for your sounds, if they're ActionScript based.  You'd have to invoke &lt;code&gt;Sound.stop()&lt;/code&gt; (AS2) or &lt;code&gt;SoundChannel.stop()&lt;/code&gt; (AS3) on each of those, or use a global volume toggle.</description>
		<content:encoded><![CDATA[<p>tunghoy,</p>
<p>Each of those child MCs has a timeline of its own.  For every timeline you want to stop, you have to invoke a <code>MovieClip.stop()</code> on it.  The simple pause mechanism on this blog (AS2 and AS3 versions) only pauses the timeline it&#8217;s in, so to pause the main timeline, you use the code as is; to pause the main timeline and a bunch of movie clips &#8230; well, you&#8217;d have to loop through the properties of the main timeline in AS2 (use a <code>for..in</code> loop), then, using <code>instanceof</code> to weed out the movie clips, invoke <code>stop()</code> on the others.  In AS3, you could use a similar approach by checking the children of the display list.</p>
<p>It gets even more complicated for your sounds, if they&#8217;re ActionScript based.  You&#8217;d have to invoke <code>Sound.stop()</code> (AS2) or <code>SoundChannel.stop()</code> (AS3) on each of those, or use a global volume toggle.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: tunghoy</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-126668</link>
		<pubDate>Thu, 31 Jan 2008 18:02:59 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-126668</guid>
					<description>Great, I'll look at that over the weekend. Adobe's tutorials are a lot better than their LiveDocs. I've also been going through the advanced AS tutorials on lynda.com (a dangerous place because I want to learn everything).

BTW -- I looked through your tutorial on pausing the timeline, but I'm having some trouble with that, also. My main timeline contains only child MCs, external sound and pause &amp;#38; play buttons. How can I get the whole thing (main timeline &amp;#38; currently playing MC) to pause? None of my stop actions are working....</description>
		<content:encoded><![CDATA[<p>Great, I&#8217;ll look at that over the weekend. Adobe&#8217;s tutorials are a lot better than their LiveDocs. I&#8217;ve also been going through the advanced AS tutorials on lynda.com (a dangerous place because I want to learn everything).</p>
<p>BTW &#8212; I looked through your tutorial on pausing the timeline, but I&#8217;m having some trouble with that, also. My main timeline contains only child MCs, external sound and pause &amp; play buttons. How can I get the whole thing (main timeline &amp; currently playing MC) to pause? None of my stop actions are working&#8230;.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-125003</link>
		<pubDate>Mon, 28 Jan 2008 03:08:04 +0000</pubDate>
		<guid>http://www.quip.net/blog/2007/flash/trust-me-as3-its-a-movie-clip#comment-125003</guid>
					<description>tunghoy,

Ha!  Well, that's cool ... I'm glad you solved it!  :-D  &lt;code&gt;trace()&lt;/code&gt; statements can be a real life saver.  There are a number of additional troubleshooting techniques that may help you even more.  Check out these:

&lt;a href=&quot;http://www.adobe.com/devnet/flash/articles/as3_debugger.html&quot; target=&quot;_blank&quot;&gt;Introducing the ActionScript 3.0 debugger&lt;/a&gt;
&lt;a href=&quot;http://www.adobe.com/devnet/flash/articles/debugging_actionscript.html&quot; target=&quot;_blank&quot;&gt;Debugging ActionScript 2.0 Code: Lifting the Blindfold&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>tunghoy,</p>
<p>Ha!  Well, that&#8217;s cool &#8230; I&#8217;m glad you solved it!  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' />   <code>trace()</code> statements can be a real life saver.  There are a number of additional troubleshooting techniques that may help you even more.  Check out these:</p>
<p><a href="http://www.adobe.com/devnet/flash/articles/as3_debugger.html" target="_blank">Introducing the ActionScript 3.0 debugger</a><br />
<a href="http://www.adobe.com/devnet/flash/articles/debugging_actionscript.html" target="_blank">Debugging ActionScript 2.0 Code: Lifting the Blindfold</a>
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
