

































<?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, 07 Feb 2012 19:55:14 +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-408770</link>
		<pubDate>Wed, 26 Aug 2009 13:30:42 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-408770</guid>
					<description>&lt;strong&gt;To Darkroom ...&lt;/strong&gt;

You're welcome!

&lt;strong&gt;To Kristi ...&lt;/strong&gt;

&lt;blockquote&gt;Please ignore my previous question, in going back through the post above (it's very long), I've found a comment about putting code on frame 2 instead of 1, and this works!&lt;/blockquote&gt;

Hey, glad you found a solution!  Good deal!  :)

&lt;strong&gt;To david ...&lt;/strong&gt;

&lt;blockquote&gt;im making a brick break game and i want to spice it up a bit. i want it so when the ball hits a brick, it will go to a random frame in that ball mc&lt;/blockquote&gt;

Sorry for the delayed reply!  I think I understand what you're asking.  Assuming your code does work, as shown, then the randomized part is the only thing that needs to change &amp;#8212; and it'll replace the number 2 inside your &lt;code&gt;gotoAndStop()&lt;/code&gt;.

First, here's what you had:

&lt;pre&gt;&lt;code&gt;onClipEvent(enterFrame) {
  if ((this.hitTest(_root.ball))) {
    _root.ball.yspeed = -_root.ball.yspeed;
    _root.ball.gotoAndStop(2);
    this.play();
  }
}&lt;/code&gt;&lt;/pre&gt;

I suspect you don't really need the &lt;code&gt;_root&lt;/code&gt; references in there, but because I don't have your file to test with, I'm going to go ahead and keep using it.  For the randomized part, you'll want to check how many frames are inside &lt;code&gt;ball&lt;/code&gt; (that's the &lt;code&gt;MovieClip._totalframes&lt;/code&gt; property), then use that number to generate a random number within the correct range.

&lt;pre&gt;&lt;code&gt;onClipEvent(enterFrame) {
  if ((this.hitTest(_root.ball))) {
    _root.ball.yspeed = -_root.ball.yspeed;
    _root.ball.gotoAndStop(
      Math.ceil(Math.random() * _root.ball._totalframes)
    );
    this.play();
  }
}&lt;/code&gt;&lt;/pre&gt;

See the difference?  Let me know if that works for you (and here's hoping this answer isn't too late to help you).

&lt;strong&gt;To Lenny ...&lt;/strong&gt;

Glad to help!

&lt;strong&gt;To Will ...&lt;/strong&gt;

I'm not exactly sure I understand your question, I'm afraid.  I &lt;em&gt;think&lt;/em&gt; the answer is yes, but I should clarify a few things.  First, if you're sending the playhead to a frame number, you don't need an array.  You can just use plain numbers, as I showed in my reply to david (just prior to my reply to Lenny in this block of replies).

When you say &quot;triggers another movie,&quot; my hunch is that you mean another movie clip, and if that's so, then all you need to do is reference that movie clip's instance name to access how many frames it has.  In that same sentence, though, you said &quot;which only goes to the next label,&quot; so you might need an array after all (simply because the array is capable of holding a list of strings, such as frame labels).

That leads to my second clarification, which is that, generally speaking, you can always target whatever movie clip you like &amp;#8212; be that the main timeline or a symbol &amp;#8212; by using a valid reference to that movie clip.  In the case of the main timeline, you can use &lt;code&gt;this&lt;/code&gt; if the code is scoped to that timeline (in other words, if the code appears in a keyframe of that timeline).  If the code is elsewhere, you can use &lt;code&gt;_parent&lt;/code&gt; to &quot;reach back&quot; from whatever nested timeline you're in.  You can also use &lt;code&gt;_root&lt;/code&gt;, as long as you understand &lt;a href=&quot;http://www.quip.net/blog/2006/flash/actionscript-20/is-root-evil&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;what &lt;code&gt;_root&lt;/code&gt; really means&lt;/a&gt;.  In the case of movie clip symbols, you use their instance names.</description>
		<content:encoded><![CDATA[<p><strong>To Darkroom &#8230;</strong></p>
<p>You&#8217;re welcome!</p>
<p><strong>To Kristi &#8230;</strong></p>
<blockquote><p>Please ignore my previous question, in going back through the post above (it&#8217;s very long), I&#8217;ve found a comment about putting code on frame 2 instead of 1, and this works!</p></blockquote>
<p>Hey, glad you found a solution!  Good deal!  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>To david &#8230;</strong></p>
<blockquote><p>im making a brick break game and i want to spice it up a bit. i want it so when the ball hits a brick, it will go to a random frame in that ball mc</p></blockquote>
<p>Sorry for the delayed reply!  I think I understand what you&#8217;re asking.  Assuming your code does work, as shown, then the randomized part is the only thing that needs to change &mdash; and it&#8217;ll replace the number 2 inside your <code>gotoAndStop()</code>.</p>
<p>First, here&#8217;s what you had:</p>
<pre><code>onClipEvent(enterFrame) {
  if ((this.hitTest(_root.ball))) {
    _root.ball.yspeed = -_root.ball.yspeed;
    _root.ball.gotoAndStop(2);
    this.play();
  }
}</code></pre>
<p>I suspect you don&#8217;t really need the <code>_root</code> references in there, but because I don&#8217;t have your file to test with, I&#8217;m going to go ahead and keep using it.  For the randomized part, you&#8217;ll want to check how many frames are inside <code>ball</code> (that&#8217;s the <code>MovieClip._totalframes</code> property), then use that number to generate a random number within the correct range.</p>
<pre><code>onClipEvent(enterFrame) {
  if ((this.hitTest(_root.ball))) {
    _root.ball.yspeed = -_root.ball.yspeed;
    _root.ball.gotoAndStop(
      Math.ceil(Math.random() * _root.ball._totalframes)
    );
    this.play();
  }
}</code></pre>
<p>See the difference?  Let me know if that works for you (and here&#8217;s hoping this answer isn&#8217;t too late to help you).</p>
<p><strong>To Lenny &#8230;</strong></p>
<p>Glad to help!</p>
<p><strong>To Will &#8230;</strong></p>
<p>I&#8217;m not exactly sure I understand your question, I&#8217;m afraid.  I <em>think</em> the answer is yes, but I should clarify a few things.  First, if you&#8217;re sending the playhead to a frame number, you don&#8217;t need an array.  You can just use plain numbers, as I showed in my reply to david (just prior to my reply to Lenny in this block of replies).</p>
<p>When you say &#8220;triggers another movie,&#8221; my hunch is that you mean another movie clip, and if that&#8217;s so, then all you need to do is reference that movie clip&#8217;s instance name to access how many frames it has.  In that same sentence, though, you said &#8220;which only goes to the next label,&#8221; so you might need an array after all (simply because the array is capable of holding a list of strings, such as frame labels).</p>
<p>That leads to my second clarification, which is that, generally speaking, you can always target whatever movie clip you like &mdash; be that the main timeline or a symbol &mdash; by using a valid reference to that movie clip.  In the case of the main timeline, you can use <code>this</code> if the code is scoped to that timeline (in other words, if the code appears in a keyframe of that timeline).  If the code is elsewhere, you can use <code>_parent</code> to &#8220;reach back&#8221; from whatever nested timeline you&#8217;re in.  You can also use <code>_root</code>, as long as you understand <a href="http://www.quip.net/blog/2006/flash/actionscript-20/is-root-evil" target="_blank" rel="nofollow">what <code>_root</code> really means</a>.  In the case of movie clip symbols, you use their instance names.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Will</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-408682</link>
		<pubDate>Wed, 26 Aug 2009 02:04:54 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-408682</guid>
					<description>Hi David,

Great Articles, i have a question on arrays of frame numbers. Can i put an array of frame numbers, that are from one movie timeline on the stage, that triggers another movie to play (which only goes to the next label) each time it reaches one of the frame numbers in the array.

Thanks</description>
		<content:encoded><![CDATA[<p>Hi David,</p>
<p>Great Articles, i have a question on arrays of frame numbers. Can i put an array of frame numbers, that are from one movie timeline on the stage, that triggers another movie to play (which only goes to the next label) each time it reaches one of the frame numbers in the array.</p>
<p>Thanks
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Lenny</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-407364</link>
		<pubDate>Mon, 17 Aug 2009 08:53:38 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-407364</guid>
					<description>Just the ticket!! - thanks very much.</description>
		<content:encoded><![CDATA[<p>Just the ticket!! - thanks very much.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: david taylor</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-400365</link>
		<pubDate>Thu, 25 Jun 2009 21:50:34 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-400365</guid>
					<description>im making a brick break game and i want to spice it up a bit.  i want it so when the ball hits a brick, it will go to a random frame in that ball mc.  

onClipEvent(enterFrame) {
if ((this.hitTest(_root.ball))) {
_root.ball.yspeed = -_root.ball.yspeed;
_root.ball.gotoAndStop(2);
this.play();
}
}

on frame two is a red ball, when i try to make it go to a random frame, it doesnt work, however, i got it to go to the second ball frame  :) help!  if you need it explained bettter please ask</description>
		<content:encoded><![CDATA[<p>im making a brick break game and i want to spice it up a bit.  i want it so when the ball hits a brick, it will go to a random frame in that ball mc.  </p>
<p>onClipEvent(enterFrame) {<br />
if ((this.hitTest(_root.ball))) {<br />
_root.ball.yspeed = -_root.ball.yspeed;<br />
_root.ball.gotoAndStop(2);<br />
this.play();<br />
}<br />
}</p>
<p>on frame two is a red ball, when i try to make it go to a random frame, it doesnt work, however, i got it to go to the second ball frame  <img src='http://www.quip.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  help!  if you need it explained bettter please ask
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Kristi Drain</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-394277</link>
		<pubDate>Wed, 27 May 2009 03:13:28 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-394277</guid>
					<description>Hi David
Please ignore my previous question, in going back through the post above (it's very long), I've found a comment about putting code on frame 2 instead of 1, and this works! yeehaa, thank you.
Cheers
Kristi</description>
		<content:encoded><![CDATA[<p>Hi David<br />
Please ignore my previous question, in going back through the post above (it&#8217;s very long), I&#8217;ve found a comment about putting code on frame 2 instead of 1, and this works! yeehaa, thank you.<br />
Cheers<br />
Kristi
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Kristi Drain</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-394276</link>
		<pubDate>Wed, 27 May 2009 03:09:34 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-394276</guid>
					<description>Hi David
I've got a project that requires much the same as Heather Adams from June 15th, 2006, further up this post. I'm having some trouble with it, so wondering if you can help please. Action Script 2 preferred.

I've got a 205 frame anim with 16 frame labels, and I need the animation to run from a random starting label, then just play normally, and when at end frame loop back to start (or frame 2 so that it doesn't trigger random label action).
I've tried the following from post above:

var labels:Array = new Array(&quot;Frame1&quot;, &quot;Frame2&quot;, &quot;Frame3&quot;, &quot;Frame4&quot;, &quot;Frame5&quot;, &quot;Frame6&quot;, &quot;Frame7&quot;, &quot;Frame8&quot;, &quot;Frame9&quot;, &quot;Frame10&quot;, &quot;Frame11&quot;, &quot;Frame12&quot;, &quot;Frame13&quot;, &quot;Frame14&quot;, &quot;Frame15&quot;, &quot;Frame16&quot;);
var index:Number = Math.floor(Math.random() * labels.length);
this.gotoAndPlay(labels[index]);

but it doesn't seam to work. On testing 23 times, the first 19 started on frame 1, then label 3, then frame 1, then label 2. Not very random. My action script is on frame 1, and was copy pasted from this post. I'm running CS3 ?? Any thoughts? I'd be very grateful for your assistance.

Cheers
Kristi</description>
		<content:encoded><![CDATA[<p>Hi David<br />
I&#8217;ve got a project that requires much the same as Heather Adams from June 15th, 2006, further up this post. I&#8217;m having some trouble with it, so wondering if you can help please. Action Script 2 preferred.</p>
<p>I&#8217;ve got a 205 frame anim with 16 frame labels, and I need the animation to run from a random starting label, then just play normally, and when at end frame loop back to start (or frame 2 so that it doesn&#8217;t trigger random label action).<br />
I&#8217;ve tried the following from post above:</p>
<p>var labels:Array = new Array(&#8221;Frame1&#8243;, &#8220;Frame2&#8243;, &#8220;Frame3&#8243;, &#8220;Frame4&#8243;, &#8220;Frame5&#8243;, &#8220;Frame6&#8243;, &#8220;Frame7&#8243;, &#8220;Frame8&#8243;, &#8220;Frame9&#8243;, &#8220;Frame10&#8243;, &#8220;Frame11&#8243;, &#8220;Frame12&#8243;, &#8220;Frame13&#8243;, &#8220;Frame14&#8243;, &#8220;Frame15&#8243;, &#8220;Frame16&#8243;);<br />
var index:Number = Math.floor(Math.random() * labels.length);<br />
this.gotoAndPlay(labels[index]);</p>
<p>but it doesn&#8217;t seam to work. On testing 23 times, the first 19 started on frame 1, then label 3, then frame 1, then label 2. Not very random. My action script is on frame 1, and was copy pasted from this post. I&#8217;m running CS3 ?? Any thoughts? I&#8217;d be very grateful for your assistance.</p>
<p>Cheers<br />
Kristi
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Darkroom</title>
		<link>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-343426</link>
		<pubDate>Sat, 31 Jan 2009 11:24:54 +0000</pubDate>
		<guid>http://www.quip.net/blog/2006/flash/how-to-jump-random-frame-label#comment-343426</guid>
					<description>hi david, i just wanted to thank you very much for this helpful post.</description>
		<content:encoded><![CDATA[<p>hi david, i just wanted to thank you very much for this helpful post.
</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-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>
</channel>
</rss>

