<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flash Actionscript 101, The First ActionScript I Ever Learned</title>
	<atom:link href="http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/</link>
	<description>FLASH :: FLEX :: AIR :: ILLUSTRATION :: ANIMATION :: WEB DEVELOPMENT</description>
	<lastBuildDate>Thu, 15 Dec 2011 05:16:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: John</title>
		<link>http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/comment-page-1/#comment-225</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 04 Mar 2009 05:44:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.taterboy.com/blog/?p=50#comment-225</guid>
		<description>Hi,
WOW! Thanks so much, this took a while for me to figure out, but I got it`-`
First I think that I got a index out of bounds error, as when I was clicking on 3 there was no reference, as the array only goes to 2, since it starts at zero. I was using  imgBtn.id = int(arrCnt); instead of what it should be imgBtn.id = int(p); as we are only using the new variable arrCnt has the  display number and not the variable p which holds the items in the array? Not sure if I say that right, but below is the whole loop, and how I got it working:

var arrCnt:int = 1; // set the starting number

for(var p:String in imageArr){

	// create new ImageButton
	var imgBtn:ImageButton = new ImageButton();

	// add a button label
	imgBtn.labelText.text = &quot;Image &quot; + int(arrCnt);

	// give the button a id from &quot;p&quot; which references the index
	// of the current item in the array.
	imgBtn.id = int(p);
	
	// set the y property using the buffHeight variable.
	imgBtn.y = buffHeight;
	imgBtn.x = 20;
	
	// add the eventListener to capture the button clicks
	imgBtn.addEventListener(MouseEvent.CLICK,clickHandler);
	
	//add the button to the stage.
	addChild(imgBtn);
	
	//update the variable with the height of this button, so the next button&#039;s y position will be below it.
	buffHeight += imgBtn.height + 5;
	arrCnt++
}

Thanks so much for your help`-`
Johnny</description>
		<content:encoded><![CDATA[<p>Hi,<br />
WOW! Thanks so much, this took a while for me to figure out, but I got it`-`<br />
First I think that I got a index out of bounds error, as when I was clicking on 3 there was no reference, as the array only goes to 2, since it starts at zero. I was using  imgBtn.id = int(arrCnt); instead of what it should be imgBtn.id = int(p); as we are only using the new variable arrCnt has the  display number and not the variable p which holds the items in the array? Not sure if I say that right, but below is the whole loop, and how I got it working:</p>
<p>var arrCnt:int = 1; // set the starting number</p>
<p>for(var p:String in imageArr){</p>
<p>	// create new ImageButton<br />
	var imgBtn:ImageButton = new ImageButton();</p>
<p>	// add a button label<br />
	imgBtn.labelText.text = &#8220;Image &#8221; + int(arrCnt);</p>
<p>	// give the button a id from &#8220;p&#8221; which references the index<br />
	// of the current item in the array.<br />
	imgBtn.id = int(p);</p>
<p>	// set the y property using the buffHeight variable.<br />
	imgBtn.y = buffHeight;<br />
	imgBtn.x = 20;</p>
<p>	// add the eventListener to capture the button clicks<br />
	imgBtn.addEventListener(MouseEvent.CLICK,clickHandler);</p>
<p>	//add the button to the stage.<br />
	addChild(imgBtn);</p>
<p>	//update the variable with the height of this button, so the next button&#8217;s y position will be below it.<br />
	buffHeight += imgBtn.height + 5;<br />
	arrCnt++<br />
}</p>
<p>Thanks so much for your help`-`<br />
Johnny</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: taterboy</title>
		<link>http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/comment-page-1/#comment-224</link>
		<dc:creator>taterboy</dc:creator>
		<pubDate>Tue, 03 Mar 2009 13:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.taterboy.com/blog/?p=50#comment-224</guid>
		<description>p is declared as a string, it is the only variable type the &quot;in&quot; for loop will except. We can parse p into an number or integer in most cases like this.

int(p) or Number(p). 

int(p) + 1; should give you a number sequence starting with 1.

If that does not work, then you can always add a new variable to count up for you. Before the for loop declare a new variable like this.

var arrCnt:int = 1; // set the starting number
for(var p:String in imageArr){
        // use the arrCnt variable to make id an integer starting at 1.
	imgBtn.id = arrCnt;
       // increase arrCnt every cycle of the array; 1,2,3,4,5,6
       arrCnt ++;
}</description>
		<content:encoded><![CDATA[<p>p is declared as a string, it is the only variable type the &#8220;in&#8221; for loop will except. We can parse p into an number or integer in most cases like this.</p>
<p>int(p) or Number(p). </p>
<p>int(p) + 1; should give you a number sequence starting with 1.</p>
<p>If that does not work, then you can always add a new variable to count up for you. Before the for loop declare a new variable like this.</p>
<p>var arrCnt:int = 1; // set the starting number<br />
for(var p:String in imageArr){<br />
        // use the arrCnt variable to make id an integer starting at 1.<br />
	imgBtn.id = arrCnt;<br />
       // increase arrCnt every cycle of the array; 1,2,3,4,5,6<br />
       arrCnt ++;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/comment-page-1/#comment-223</link>
		<dc:creator>John</dc:creator>
		<pubDate>Tue, 03 Mar 2009 05:25:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.taterboy.com/blog/?p=50#comment-223</guid>
		<description>Yeah I know what you mean, typos are so easy to make. I am glad I caught it too`-`
Can I ask--&gt; how would I change the numbering to not include the first array item as 0? That is to have 1,2,3 instead of 0,1,2?

I see in the As code that there is :
// add a button label
	imgBtn.labelText.text = &quot;Image &quot; + p;	

	// give the button a id from &quot;p&quot; which references the index
	// of the current item in the array.
	imgBtn.id = int(p);

I tried using &quot;p+1&quot; in step up one number but no luck.

Thanks so much for showing these examples on your blog`-``
Johnny</description>
		<content:encoded><![CDATA[<p>Yeah I know what you mean, typos are so easy to make. I am glad I caught it too`-`<br />
Can I ask&#8211;&gt; how would I change the numbering to not include the first array item as 0? That is to have 1,2,3 instead of 0,1,2?</p>
<p>I see in the As code that there is :<br />
// add a button label<br />
	imgBtn.labelText.text = &#8220;Image &#8221; + p;	</p>
<p>	// give the button a id from &#8220;p&#8221; which references the index<br />
	// of the current item in the array.<br />
	imgBtn.id = int(p);</p>
<p>I tried using &#8220;p+1&#8243; in step up one number but no luck.</p>
<p>Thanks so much for showing these examples on your blog`-&#8220;<br />
Johnny</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: taterboy</title>
		<link>http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/comment-page-1/#comment-221</link>
		<dc:creator>taterboy</dc:creator>
		<pubDate>Mon, 02 Mar 2009 14:08:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.taterboy.com/blog/?p=50#comment-221</guid>
		<description>Thanks for catching that, I really need a good editor. Typos, are one of the biggest bug creators.</description>
		<content:encoded><![CDATA[<p>Thanks for catching that, I really need a good editor. Typos, are one of the biggest bug creators.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.taterboy.com/blog/2008/12/flash-actionscript-101-the-first-actionscript-i-ever-learned/comment-page-1/#comment-219</link>
		<dc:creator>John</dc:creator>
		<pubDate>Sun, 01 Mar 2009 10:30:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.taterboy.com/blog/?p=50#comment-219</guid>
		<description>WOW! Great post, especially for a newbie like me`-`
I found a typo, or at least I could not get it working until I changed fruit to fruitArr in the for() Loop: section.

Thanks so much for making this post, I feel thank to you that I am actually understanding As 3`-`

Next I have to learn how to make such a cool interface too`-`

Thanks,
Johnny</description>
		<content:encoded><![CDATA[<p>WOW! Great post, especially for a newbie like me`-`<br />
I found a typo, or at least I could not get it working until I changed fruit to fruitArr in the for() Loop: section.</p>
<p>Thanks so much for making this post, I feel thank to you that I am actually understanding As 3`-`</p>
<p>Next I have to learn how to make such a cool interface too`-`</p>
<p>Thanks,<br />
Johnny</p>
]]></content:encoded>
	</item>
</channel>
</rss>

