<?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 Jump to a Random Frame Label</title>
	<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label</link>
	<description>Luck is the residue of good design.</description>
	<pubDate>Tue, 06 Jan 2009 21:26:21 +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/how-to-jump-random-frame-label#comment-247340</link>
		<pubDate>Tue, 12 Aug 2008 13:24:22 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-247340</guid>
					<description>Gary,

If you're testing from within Flash, the loading aspect shouldn't be an issue, so I'm still a bit puzzled.  Still, I'm glad that you feel more comfortable about the numeric version.

For sake of troubleshooting, I suggest you copy/paste this same (or similar) code into a brand new FLA with very little content &amp;#8212; perhaps a few simple shapes &amp;#8212; and see if you run into the same limitation (you shouldn't).  That may help you pinpoint what's going on in your actual content FLA.</description>
		<content:encoded><![CDATA[<p>Gary,</p>
<p>If you&#8217;re testing from within Flash, the loading aspect shouldn&#8217;t be an issue, so I&#8217;m still a bit puzzled.  Still, I&#8217;m glad that you feel more comfortable about the numeric version.</p>
<p>For sake of troubleshooting, I suggest you copy/paste this same (or similar) code into a brand new FLA with very little content &mdash; perhaps a few simple shapes &mdash; and see if you run into the same limitation (you shouldn&#8217;t).  That may help you pinpoint what&#8217;s going on in your actual content FLA.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gary</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-247078</link>
		<pubDate>Tue, 12 Aug 2008 05:02:27 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-247078</guid>
					<description>I changed the code as you suggested. It's still doing the same thing, but in a measure of troubleshooting, I allowed the last frame to loop back to frame one so that the entire file would be loaded. When refreshing the web page with the flash file, it still won't start on any frame higher than 231, but when it loops back, it works just fine. Therefore, I guess it's just not loading fast enough for my images. It's a rather extensive slideshow with lots of pictures, animated text and logos. I guess it's back to the drawing board for this one.

Thanks for your help. BTW, I like the new code better. It just feels right.


Thanks,
Gary</description>
		<content:encoded><![CDATA[<p>I changed the code as you suggested. It&#8217;s still doing the same thing, but in a measure of troubleshooting, I allowed the last frame to loop back to frame one so that the entire file would be loaded. When refreshing the web page with the flash file, it still won&#8217;t start on any frame higher than 231, but when it loops back, it works just fine. Therefore, I guess it&#8217;s just not loading fast enough for my images. It&#8217;s a rather extensive slideshow with lots of pictures, animated text and logos. I guess it&#8217;s back to the drawing board for this one.</p>
<p>Thanks for your help. BTW, I like the new code better. It just feels right.</p>
<p>Thanks,<br />
Gary
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-246232</link>
		<pubDate>Mon, 11 Aug 2008 02:39:57 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-246232</guid>
					<description>&lt;strong&gt;To danny ...&lt;/strong&gt;

&lt;blockquote&gt;when i click to go back to “homepage” (for example) the whole thing turns a mess… jumping from one frame to another…….

it’s just like if the random mc code was still workin outside the mc!!!&lt;/blockquote&gt;

Apologies for the late reply!

Off the top of my head, I'm afraid I'm not sure what might be causing this &amp;#8212; actually, not sure I can even envision it.  The only thing that should be telling the movie clip to jump anywhere are your series of &lt;code&gt;gotoAndPlay()&lt;/code&gt; calls, and if you're preceding that with the &lt;code&gt;this&lt;/code&gt; keyword (and assuming those statements are inside the keyframes of the movie clip in question), then only that movie clip should be jumping around.

But maybe that's just it?  Is that movie clip continuing to play, even when you send the main timeline elsewhere?  If so, you can give that movie clip an instance name and invoke &lt;code&gt;MovieClip.stop()&lt;/code&gt; on it ... or hide it by setting its &lt;code&gt;MovieClip._visible&lt;/code&gt; property to &lt;code&gt;false&lt;/code&gt;.  Do any of these suggestions make sense?  I might be missing the mark completely, so let me know if I can re-phrase to try to suggest a few other avenues.

&lt;strong&gt;To Gary ...&lt;/strong&gt;

&lt;blockquote&gt;First off, I’m totally new to AS and don’t know how to label a frame&lt;/blockquote&gt;

You'll be pleased to hear it's super easy.  :)  I generally create a Timeline layer just for labels, same as for ActionScript.  Add a keyframe to whatever frame you want labeled, then click that frame to select it.  Look at the Property inspector, and you'll see right where you can specify your label.

&lt;blockquote&gt;t seems that if you just use the frame number, it works just as well&lt;/blockquote&gt;

Yes.  The &lt;code&gt;MovieClip.gotoAndPlay()&lt;/code&gt; method accepts either a number (for frames) or a string (for labels).

&lt;blockquote&gt;but if I add a frame number higher than 231, it just goes to frame 231 every time and won’t go any higher. It may still go to 6, 66, 126, or 186, but won’t go higher than 231. Is this because I really need to actually label the frames?&lt;/blockquote&gt;

It shouldn't matter, but the fact that it keeps getting stuck on 231 for you makes me wonder if your timeline has more than 231 frames.  If it doesn't, then 231 is the end of the line.  If you choose to use frame numbers rather than labels, you should rewrite the &lt;code&gt;getRandomLabel()&lt;/code&gt; function like this:

&lt;pre&gt;&lt;code&gt;function getRandomFrame():Number {
  var labels:Array = new Array(6, 66, 126, 186);
  var index:Number = Math.floor(Math.random() * labels.length);
  return labels[index];
}&lt;/code&gt;&lt;/pre&gt;

... not that it makes any difference what the function is called, but at least this way you're actually returning numbers, rather than strings (notice the &lt;code&gt;:Number&lt;/code&gt; datatype on the function's return value, and the omitted quotation marks on the array's items).

You should be able to put any numbers in there you please, as long as the timeline that contains this code has that many frames.  If you have especially heavy assets in that particular timeline, it might be that Flash Player is still &lt;em&gt;loading&lt;/em&gt; those frames, while &lt;code&gt;gotoAndPlay()&lt;/code&gt; makes the attempt to jump to a frame that doesn't exist ... yet.

Might that be it?</description>
		<content:encoded><![CDATA[<p><strong>To danny &#8230;</strong></p>
<blockquote><p>when i click to go back to “homepage” (for example) the whole thing turns a mess… jumping from one frame to another…….</p>
<p>it’s just like if the random mc code was still workin outside the mc!!!</p></blockquote>
<p>Apologies for the late reply!</p>
<p>Off the top of my head, I&#8217;m afraid I&#8217;m not sure what might be causing this &mdash; actually, not sure I can even envision it.  The only thing that should be telling the movie clip to jump anywhere are your series of <code>gotoAndPlay()</code> calls, and if you&#8217;re preceding that with the <code>this</code> keyword (and assuming those statements are inside the keyframes of the movie clip in question), then only that movie clip should be jumping around.</p>
<p>But maybe that&#8217;s just it?  Is that movie clip continuing to play, even when you send the main timeline elsewhere?  If so, you can give that movie clip an instance name and invoke <code>MovieClip.stop()</code> on it &#8230; or hide it by setting its <code>MovieClip._visible</code> property to <code>false</code>.  Do any of these suggestions make sense?  I might be missing the mark completely, so let me know if I can re-phrase to try to suggest a few other avenues.</p>
<p><strong>To Gary &#8230;</strong></p>
<blockquote><p>First off, I’m totally new to AS and don’t know how to label a frame</p></blockquote>
<p>You&#8217;ll be pleased to hear it&#8217;s super easy.  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I generally create a Timeline layer just for labels, same as for ActionScript.  Add a keyframe to whatever frame you want labeled, then click that frame to select it.  Look at the Property inspector, and you&#8217;ll see right where you can specify your label.</p>
<blockquote><p>t seems that if you just use the frame number, it works just as well</p></blockquote>
<p>Yes.  The <code>MovieClip.gotoAndPlay()</code> method accepts either a number (for frames) or a string (for labels).</p>
<blockquote><p>but if I add a frame number higher than 231, it just goes to frame 231 every time and won’t go any higher. It may still go to 6, 66, 126, or 186, but won’t go higher than 231. Is this because I really need to actually label the frames?</p></blockquote>
<p>It shouldn&#8217;t matter, but the fact that it keeps getting stuck on 231 for you makes me wonder if your timeline has more than 231 frames.  If it doesn&#8217;t, then 231 is the end of the line.  If you choose to use frame numbers rather than labels, you should rewrite the <code>getRandomLabel()</code> function like this:</p>
<pre><code>function getRandomFrame():Number {
  var labels:Array = new Array(6, 66, 126, 186);
  var index:Number = Math.floor(Math.random() * labels.length);
  return labels[index];
}</code></pre>
<p>&#8230; not that it makes any difference what the function is called, but at least this way you&#8217;re actually returning numbers, rather than strings (notice the <code>:Number</code> datatype on the function&#8217;s return value, and the omitted quotation marks on the array&#8217;s items).</p>
<p>You should be able to put any numbers in there you please, as long as the timeline that contains this code has that many frames.  If you have especially heavy assets in that particular timeline, it might be that Flash Player is still <em>loading</em> those frames, while <code>gotoAndPlay()</code> makes the attempt to jump to a frame that doesn&#8217;t exist &#8230; yet.</p>
<p>Might that be it?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gary</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-245757</link>
		<pubDate>Sun, 10 Aug 2008 15:50:43 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-245757</guid>
					<description>Thanks for the script. I tried this out and it worked great (using gotoAndPlay in the last line) and got all excited, but then when I finished my very long animation, it only works to a point. First off, I'm totally new to AS and don't know how to label a frame, but it seems that if you just use the frame number, it works just as well. Only, it quits working if the frame number is too high. For instance, this works fine:

function getRandomLabel():String {
  var labels:Array = new Array(&quot;6&quot;, &quot;66&quot;, &quot;126&quot;, &quot;186&quot;);
  var index:Number = Math.floor(Math.random() * labels.length);
  return labels[index];
}
this.gotoAndPlay(getRandomLabel());

but if I add a frame number higher than 231, it just goes to frame 231 every time and won't go any higher. It may still go to 6, 66, 126, or 186, but won't go higher than 231. Is this because I really need to actually label the frames? If so, how do I?

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Thanks for the script. I tried this out and it worked great (using gotoAndPlay in the last line) and got all excited, but then when I finished my very long animation, it only works to a point. First off, I&#8217;m totally new to AS and don&#8217;t know how to label a frame, but it seems that if you just use the frame number, it works just as well. Only, it quits working if the frame number is too high. For instance, this works fine:</p>
<p>function getRandomLabel():String {<br />
  var labels:Array = new Array(&#8221;6&#8243;, &#8220;66&#8243;, &#8220;126&#8243;, &#8220;186&#8243;);<br />
  var index:Number = Math.floor(Math.random() * labels.length);<br />
  return labels[index];<br />
}<br />
this.gotoAndPlay(getRandomLabel());</p>
<p>but if I add a frame number higher than 231, it just goes to frame 231 every time and won&#8217;t go any higher. It may still go to 6, 66, 126, or 186, but won&#8217;t go higher than 231. Is this because I really need to actually label the frames? If so, how do I?</p>
<p>Thanks in advance.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: danny luis</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-213959</link>
		<pubDate>Wed, 02 Jul 2008 13:32:11 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-213959</guid>
					<description>Hi David!!... first off all congratulations for this amazing and helpfull blog you have!!... i'm a young designer trying to learn some cool stuff in flash... i was trying to make a random slideshow in a website whit this actionscript codes you've provided in this post... 

but the thing is, the random slideshow is workin' fine, i click to go to the frame where the random slideshow mc is and it works just fine, but when i click to go back to &quot;homepage&quot; (for example) the whole thing turns a mess... jumping from one frame to another.......

it's just like if the random mc code was still workin outside the mc!!!

Could you give me some help??

best regards, Danny</description>
		<content:encoded><![CDATA[<p>Hi David!!&#8230; first off all congratulations for this amazing and helpfull blog you have!!&#8230; i&#8217;m a young designer trying to learn some cool stuff in flash&#8230; i was trying to make a random slideshow in a website whit this actionscript codes you&#8217;ve provided in this post&#8230; </p>
<p>but the thing is, the random slideshow is workin&#8217; fine, i click to go to the frame where the random slideshow mc is and it works just fine, but when i click to go back to &#8220;homepage&#8221; (for example) the whole thing turns a mess&#8230; jumping from one frame to another&#8230;&#8230;.</p>
<p>it&#8217;s just like if the random mc code was still workin outside the mc!!!</p>
<p>Could you give me some help??</p>
<p>best regards, Danny
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160457</link>
		<pubDate>Thu, 10 Apr 2008 19:40:21 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160457</guid>
					<description>Adam,

There you go!  Cool!</description>
		<content:encoded><![CDATA[<p>Adam,</p>
<p>There you go!  Cool!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Adam Gabardy</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160454</link>
		<pubDate>Thu, 10 Apr 2008 19:36:40 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160454</guid>
					<description>Perfect!  A little extra reading would have done me well, I guess.

I changed the line to read:

this.gotoAndPlay(labels[currentLabel]);

Thank you for your help!</description>
		<content:encoded><![CDATA[<p>Perfect!  A little extra reading would have done me well, I guess.</p>
<p>I changed the line to read:</p>
<p>this.gotoAndPlay(labels[currentLabel]);</p>
<p>Thank you for your help!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160436</link>
		<pubDate>Thu, 10 Apr 2008 19:06:28 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160436</guid>
					<description>Adam,

I wonder if you're running into the issue described in &quot;&lt;a href=&quot;http://www.quip.net/blog/2006/flash/actionscript-20/gotoandplay-with-scenes&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;Why Doesn't _root.gotoAndPlay() Work with Scenes&lt;/a&gt;&quot;?</description>
		<content:encoded><![CDATA[<p>Adam,</p>
<p>I wonder if you&#8217;re running into the issue described in &#8220;<a href="http://www.quip.net/blog/2006/flash/actionscript-20/gotoandplay-with-scenes" target="_blank" rel="nofollow">Why Doesn&#8217;t _root.gotoAndPlay() Work with Scenes</a>&#8220;?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Adam Gabardy</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160402</link>
		<pubDate>Thu, 10 Apr 2008 18:12:26 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-160402</guid>
					<description>David,

I've applied this code and it works wonderfully with a single scene.  However, when I try to apply it to one scene in an environment with many of them, it doesn't seem to work quite right.  I only have labels on the last scene, but when it runs the gotoNextLabel it returns to the first frame of the first scene.  For some reason it seems to ignore the actual frame labels.

This scene on its own works perfectly.  When it's part of a movie with other scenes it acts a little strange.  Am I missing something?</description>
		<content:encoded><![CDATA[<p>David,</p>
<p>I&#8217;ve applied this code and it works wonderfully with a single scene.  However, when I try to apply it to one scene in an environment with many of them, it doesn&#8217;t seem to work quite right.  I only have labels on the last scene, but when it runs the gotoNextLabel it returns to the first frame of the first scene.  For some reason it seems to ignore the actual frame labels.</p>
<p>This scene on its own works perfectly.  When it&#8217;s part of a movie with other scenes it acts a little strange.  Am I missing something?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: David Stiller</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-156118</link>
		<pubDate>Tue, 01 Apr 2008 14:42:21 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-156118</guid>
					<description>Joyce,

Buttons and images shouldn't harm a thing, though you didn't mention how you used those in conjunction with the sample code.  Is your FLA document configured for ActionScript 2.0?  Often, it helps to start small and build your way toward a goal.  Start a FLA file without buttons and images &amp;#8212; just use shapes on, say, three different frame &amp;#8212; and use that as a proof of concept.  When that works (it should!) replace the shapes with images.  When that works, increase the images from three to eight, etc.  Then add your buttons.</description>
		<content:encoded><![CDATA[<p>Joyce,</p>
<p>Buttons and images shouldn&#8217;t harm a thing, though you didn&#8217;t mention how you used those in conjunction with the sample code.  Is your FLA document configured for ActionScript 2.0?  Often, it helps to start small and build your way toward a goal.  Start a FLA file without buttons and images &mdash; just use shapes on, say, three different frame &mdash; and use that as a proof of concept.  When that works (it should!) replace the shapes with images.  When that works, increase the images from three to eight, etc.  Then add your buttons.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
