<?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: Introduction to AS3 classes</title>
	<atom:link href="http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/</link>
	<description>italian geek and PROgrammer</description>
	<lastBuildDate>Fri, 10 Feb 2012 12:12:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Danny Phantom</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-984026</link>
		<dc:creator>Danny Phantom</dc:creator>
		<pubDate>Thu, 03 Nov 2011 11:42:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-984026</guid>
		<description>@Paul.

Better Management of Code -
The Final Product Runs Faster Than AS2.

The better it gets the more complex it is to implement it. AS2 is by no means better than AS3 and I can surely say that AS3 is better than AS2.

It takes less code in AS2 but you get less performance too. So keep that in mind.</description>
		<content:encoded><![CDATA[<p>@Paul.</p>
<p>Better Management of Code -<br />
The Final Product Runs Faster Than AS2.</p>
<p>The better it gets the more complex it is to implement it. AS2 is by no means better than AS3 and I can surely say that AS3 is better than AS2.</p>
<p>It takes less code in AS2 but you get less performance too. So keep that in mind.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taizyd</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-969613</link>
		<dc:creator>Taizyd</dc:creator>
		<pubDate>Tue, 18 Oct 2011 08:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-969613</guid>
		<description>I these AS3 platform engine blogs had comments explaining how it all worked</description>
		<content:encoded><![CDATA[<p>I these AS3 platform engine blogs had comments explaining how it all worked</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-954162</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Sun, 02 Oct 2011 10:34:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-954162</guid>
		<description>It is COMPLETELY beyond my understanding how ANYONE can actually claim that this AS3 is superior to AS2. With all these Classes and Methods and what not yesterday it took me 45 lines of AS3 code to write something which started with a single button onstage and at the click of this button moved it off stage and placed 6 other buttons on stage. In AS 2 it would have taken only 2 timeline frames and a single line of code to achieve the EXACT same effect.

Now my problem is that the above needs to be inserted into the beginning of another project as the second project will be accessible from any one of the 6 buttons now onstage. Now the above has its own Main.as and obviously the second project also has its own Main.as . Now how the HECK do I combine the two. Even the code in this tutorial throws up all kinds of errors.

Sorry if I sound frustrated. I dont want to learn this AS3 but I guess I will have to or get left behind.

Paul</description>
		<content:encoded><![CDATA[<p>It is COMPLETELY beyond my understanding how ANYONE can actually claim that this AS3 is superior to AS2. With all these Classes and Methods and what not yesterday it took me 45 lines of AS3 code to write something which started with a single button onstage and at the click of this button moved it off stage and placed 6 other buttons on stage. In AS 2 it would have taken only 2 timeline frames and a single line of code to achieve the EXACT same effect.</p>
<p>Now my problem is that the above needs to be inserted into the beginning of another project as the second project will be accessible from any one of the 6 buttons now onstage. Now the above has its own Main.as and obviously the second project also has its own Main.as . Now how the HECK do I combine the two. Even the code in this tutorial throws up all kinds of errors.</p>
<p>Sorry if I sound frustrated. I dont want to learn this AS3 but I guess I will have to or get left behind.</p>
<p>Paul</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kev Man</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-948595</link>
		<dc:creator>Kev Man</dc:creator>
		<pubDate>Tue, 27 Sep 2011 19:30:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-948595</guid>
		<description>Whatever you do, dont start with something simple and build up.  
By all means, jump right in and overload us with code.  Make sure you dont break it down and explain the 4 main parts.  
Oh, and dont follow up with a how to implement this into your flash.
Noobs hate it when you give them the information they need and not confuse them with a bunch of other stuff.</description>
		<content:encoded><![CDATA[<p>Whatever you do, dont start with something simple and build up.<br />
By all means, jump right in and overload us with code.  Make sure you dont break it down and explain the 4 main parts.<br />
Oh, and dont follow up with a how to implement this into your flash.<br />
Noobs hate it when you give them the information they need and not confuse them with a bunch of other stuff.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joe Sacher</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-352835</link>
		<dc:creator>Joe Sacher</dc:creator>
		<pubDate>Fri, 12 Dec 2008 19:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-352835</guid>
		<description>I&#039;m new to flash and learning AS3, but experienced in other languages.  This keys.as seems great if you are only ever using arrow and space.  Expanding, however is problematic.  Should there be a method for each key?

Why not:
package 
{
	import flash.events.KeyboardEvent;
	public class keys
	{
		public const LEFT_ARROW:int = 37;
		public const RIGHT_ARROW:int = 39;
		public const UP_ARROW:int = 38;
		public const DOWN_ARROW:int = 40;
		public const SPACE_BAR:int = 32;
		
		public var keysTracked:Array;
		
		public function keys(movieclip)
		{
			keysTracked = new Array();
			
			movieclip.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
			movieclip.stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
		}
		
		public function trackKey(keyCode:int):void
		{
			keysTracked[keyCode] = false;
		}
		
		public function unTrackKey(keyCode:int):void
		{
			keysTracked[keyCode] = undefined;
		}
		
		public function isKeyDown(keyCode:int)
		{
			return keysTracked[keyCode];
		}
		
		function keyDownHandler(event:KeyboardEvent)
		{
			if(keysTracked[event.keyCode] != undefined)
			{
				keysTracked[event.keyCode] = true;
			}
		}
		
		function keyUpHandler(event:KeyboardEvent)
		{
			if(keysTracked[event.keyCode] != undefined)
			{
				keysTracked[event.keyCode] = false;
			}
		}

	}
}

To add a key, add a constant for it.  Or you can even call this with an integer, instead of the constants if you really want.

myInput = new keys(keySprite);
myInput.trackKey(myInput.UP_ARROW);
myInput.trackKey(myInput.DOWN_ARROW);
myInput.trackKey(myInput.LEFT_ARROW);
myInput.trackKey(myInput.RIGHT_ARROW);
myInput.trackKey(myInput.SPACE_BAR);

Test with:
myInput.isKeyDown(myInput.UP_ARROW);</description>
		<content:encoded><![CDATA[<p>I&#8217;m new to flash and learning AS3, but experienced in other languages.  This keys.as seems great if you are only ever using arrow and space.  Expanding, however is problematic.  Should there be a method for each key?</p>
<p>Why not:<br />
package<br />
{<br />
	import flash.events.KeyboardEvent;<br />
	public class keys<br />
	{<br />
		public const LEFT_ARROW:int = 37;<br />
		public const RIGHT_ARROW:int = 39;<br />
		public const UP_ARROW:int = 38;<br />
		public const DOWN_ARROW:int = 40;<br />
		public const SPACE_BAR:int = 32;</p>
<p>		public var keysTracked:Array;</p>
<p>		public function keys(movieclip)<br />
		{<br />
			keysTracked = new Array();</p>
<p>			movieclip.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);<br />
			movieclip.stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);<br />
		}</p>
<p>		public function trackKey(keyCode:int):void<br />
		{<br />
			keysTracked[keyCode] = false;<br />
		}</p>
<p>		public function unTrackKey(keyCode:int):void<br />
		{<br />
			keysTracked[keyCode] = undefined;<br />
		}</p>
<p>		public function isKeyDown(keyCode:int)<br />
		{<br />
			return keysTracked[keyCode];<br />
		}</p>
<p>		function keyDownHandler(event:KeyboardEvent)<br />
		{<br />
			if(keysTracked[event.keyCode] != undefined)<br />
			{<br />
				keysTracked[event.keyCode] = true;<br />
			}<br />
		}</p>
<p>		function keyUpHandler(event:KeyboardEvent)<br />
		{<br />
			if(keysTracked[event.keyCode] != undefined)<br />
			{<br />
				keysTracked[event.keyCode] = false;<br />
			}<br />
		}</p>
<p>	}<br />
}</p>
<p>To add a key, add a constant for it.  Or you can even call this with an integer, instead of the constants if you really want.</p>
<p>myInput = new keys(keySprite);<br />
myInput.trackKey(myInput.UP_ARROW);<br />
myInput.trackKey(myInput.DOWN_ARROW);<br />
myInput.trackKey(myInput.LEFT_ARROW);<br />
myInput.trackKey(myInput.RIGHT_ARROW);<br />
myInput.trackKey(myInput.SPACE_BAR);</p>
<p>Test with:<br />
myInput.isKeyDown(myInput.UP_ARROW);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-341498</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Sun, 23 Nov 2008 06:55:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-341498</guid>
		<description>Tasos, as i understand you can use the Stage class only as a property of DisplayObject class. It is not globally accessible.

To use your expression (stage.addEventListener...) keys class should Extend any DisplayObject class (Sprite for example). 

Author made an universal class keys that can be used anywhere in platform games, so he did not use here any excess things.</description>
		<content:encoded><![CDATA[<p>Tasos, as i understand you can use the Stage class only as a property of DisplayObject class. It is not globally accessible.</p>
<p>To use your expression (stage.addEventListener&#8230;) keys class should Extend any DisplayObject class (Sprite for example). </p>
<p>Author made an universal class keys that can be used anywhere in platform games, so he did not use here any excess things.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tasos</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-338250</link>
		<dc:creator>tasos</dc:creator>
		<pubDate>Tue, 18 Nov 2008 23:35:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-338250</guid>
		<description>Hello, 

On that part of the code:

public function keys(movieclip) 
{
movieclip.stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);            movieclip.stage.addEventListener(KeyboardEvent.KEY_UP, key_up);
}

why are you using a movieclip to access the stage?
couldn&#039;t you do something like 

stage.addEventListener(KeyboardEvent.KEY_UP, key_up)

ommiting the movieclip object?

Thank you!</description>
		<content:encoded><![CDATA[<p>Hello, </p>
<p>On that part of the code:</p>
<p>public function keys(movieclip)<br />
{<br />
movieclip.stage.addEventListener(KeyboardEvent.KEY_DOWN, key_down);            movieclip.stage.addEventListener(KeyboardEvent.KEY_UP, key_up);<br />
}</p>
<p>why are you using a movieclip to access the stage?<br />
couldn&#8217;t you do something like </p>
<p>stage.addEventListener(KeyboardEvent.KEY_UP, key_up)</p>
<p>ommiting the movieclip object?</p>
<p>Thank you!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anton</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-335140</link>
		<dc:creator>Anton</dc:creator>
		<pubDate>Sat, 15 Nov 2008 20:45:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-335140</guid>
		<description>Hello! I&#039;m from Russia. Sorry for my poor english.
It&#039;s a very good example. Thank you.

But I did not understand one thing. Why did you use the functions like keys.is_up, keys.is_down and so on? 

I think that it is easier to use just properties of the keys class like keys.press_up, keys.press_down etc... (of course, you should before change the access modifiers from private to public for these properties)

Maybe I&#039;m wrong...</description>
		<content:encoded><![CDATA[<p>Hello! I&#8217;m from Russia. Sorry for my poor english.<br />
It&#8217;s a very good example. Thank you.</p>
<p>But I did not understand one thing. Why did you use the functions like keys.is_up, keys.is_down and so on? </p>
<p>I think that it is easier to use just properties of the keys class like keys.press_up, keys.press_down etc&#8230; (of course, you should before change the access modifiers from private to public for these properties)</p>
<p>Maybe I&#8217;m wrong&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael W</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-317756</link>
		<dc:creator>Michael W</dc:creator>
		<pubDate>Wed, 29 Oct 2008 20:51:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-317756</guid>
		<description>Yeah, that solved it, thanks man! ;-)</description>
		<content:encoded><![CDATA[<p>Yeah, that solved it, thanks man! ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prankard</title>
		<link>http://www.emanueleferonato.com/2008/10/27/introduction-to-as3-classes/#comment-316495</link>
		<dc:creator>Prankard</dc:creator>
		<pubDate>Tue, 28 Oct 2008 16:14:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.emanueleferonato.com/?p=599#comment-316495</guid>
		<description>The code doesn&#039;t work for me. Might be because I&#039;ve gotten strict mode turned on in CS3 (which is on by default).
That&#039;s in File&gt;Publish Settings&gt;Actionscript 3.0 Settings&gt;Strict Mode.

Basically you forgot to declare your my_input variable and my Output throws errors whenever you try to access it.

Add:
private var my_input:keys;
below the &quot;public class all_in_one extends Sprite&quot;

And then it works.</description>
		<content:encoded><![CDATA[<p>The code doesn&#8217;t work for me. Might be because I&#8217;ve gotten strict mode turned on in CS3 (which is on by default).<br />
That&#8217;s in File&gt;Publish Settings&gt;Actionscript 3.0 Settings&gt;Strict Mode.</p>
<p>Basically you forgot to declare your my_input variable and my Output throws errors whenever you try to access it.</p>
<p>Add:<br />
private var my_input:keys;<br />
below the &#8220;public class all_in_one extends Sprite&#8221;</p>
<p>And then it works.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 6/11 queries in 0.019 seconds using disk: basic

Served from: www.emanueleferonato.com @ 2012-02-10 22:12:37 -->
