<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Blog</title>
	<atom:link href="http://ayumiloveflash.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ayumiloveflash.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Mon, 11 Oct 2010 00:49:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='ayumiloveflash.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>My Blog</title>
		<link>http://ayumiloveflash.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://ayumiloveflash.wordpress.com/osd.xml" title="My Blog" />
	<atom:link rel='hub' href='http://ayumiloveflash.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Useful ActionScript 3 Code: Editing Textfield using SetTextFormat</title>
		<link>http://ayumiloveflash.wordpress.com/2010/10/08/useful-actionscript-3-code-editing-textfield-using-settextformat/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/10/08/useful-actionscript-3-code-editing-textfield-using-settextformat/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 23:57:50 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=240</guid>
		<description><![CDATA[patspats (Kirupan Member) post an interesting problem which is how to edit a textfield with multiple different colors for a textfield, or to simplify it: click on color button and write in textarea with that color font. Below is his quote. hi everyone I want to do as follows: * click a &#8220;red&#8221; button * [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=240&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kirupa.com/forum/showthread.php?t=355228">patspats (Kirupan Member)</a> post an interesting problem which is how to edit a textfield with multiple different colors for a textfield, or to simplify it: click on color button and write in textarea with that color font. Below is his quote.</p>
<blockquote><p>hi everyone<br />
I want to do as follows:<br />
* click a &#8220;red&#8221; button<br />
* write in textarea with red color font<br />
* click &#8220;blue&#8221; button<br />
* write in textarea with blue color font<br />
Isn&#8217;t this possible in flash 10 using AS3 ??????</p>
<p>I tried using setTextFormat but the problem is i have to have text before inserting format on that.</p>
<p>Please somebody tell me how to do this?????<br />
Thanks alot in advance<br />
Regards</p></blockquote>
<p>Below is the solution after understanding his problem. It took me 30 minutes to get to this solution. At first, I used KeyboardEvent.DOWN but it does not work well since it takes into account of all keyboard button clicks (includes arrow keys). Using the replaceText function provided in TextField does not solve it as it resets all htmlText colors and convert it into normal text.</p>
<p>The key solution is the Event.CHANGE that tracks changes done within the textfield. This means user entering new text or removing text, but its not affected by user pressing the arrow keys or ESC. It also solves the replaceText method and it does not require my side to find out the exact caretIndex to add the new html text with the color settings like:</p>
<pre class="brush: as3;">
this._textField.htmlText += &quot;&lt;font color='#FF0000'&gt;red&lt;/font&gt;&quot;;
</pre>
<p>Preview of the SWF: http://megaswf.com/serve/56321/</p>
<pre class="brush: as3;">
package
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;

	/**
	 * ...
	 * @author Ayumilove
	 */
	public class Main extends Sprite
	{

		private var _red:Sprite;
		private var _blue:Sprite;
		private var _textField:TextField;
		private var _textFormat:TextFormat;
		private var _isColorSwitched:Boolean;
		private var _currentColor:String;

		private var _boldTx:TextField;
		private var _italicTx:TextField;

		public function Main():void
		{
			if (super.stage) this.init();
			else super.addEventListener(Event.ADDED_TO_STAGE, this.init);
		}

		private function init(event:Event = null):void
		{
			super.removeEventListener(Event.ADDED_TO_STAGE, this.init);
			this.initColorButton();
			this.initTextField();
		}

		private function initColorButton():void
		{
			this._red = new Sprite();
			this._blue = new Sprite();
			var buttons:Array = [this._red,this._blue];
			var colors:Array = [0xFF0000, 0x0000FF];
			var sp:Sprite;
			var i:int = buttons.length;;

			while (i--)
			{
				sp = buttons[i];
				sp.x = 10;
				sp.y = 25 * i + 125;
				sp.graphics.beginFill(colors[i]);
				sp.graphics.drawRect(0, 0, 20, 20);
				sp.graphics.endFill();
				super.addChild(sp);
				sp.addEventListener(MouseEvent.CLICK, this.switchTextFontColor);
			}
		}

		private function initTextField():void
		{
			this._textFormat = new TextFormat();
			this._textFormat.size = 20;

			this._textField = new TextField();
			this._textField.defaultTextFormat = this._textFormat;
			this._textField.x =
			this._textField.y = 10;
			this._textField.border = true;
			this._textField.type = TextFieldType.INPUT;
			this._textField.autoSize = TextFieldAutoSize.LEFT;
			this._textField.htmlText = &quot;Hello Ayumilove&quot;;
			this._textField.addEventListener(Event.CHANGE, this.changeHandler);
			super.addChild(this._textField);

			this._boldTx = new TextField();
			this._boldTx.mouseEnabled = true;
			this._boldTx.selectable = false;
			this._boldTx.htmlText = &quot;&lt;b&gt;Bold&lt;/b&gt;&quot;;
			this._boldTx.x = 10;
			this._boldTx.y = 175;
			this._boldTx.addEventListener(MouseEvent.CLICK, this.updateTextFormat);
			super.addChild(this._boldTx);

			this._italicTx = new TextField();
			this._italicTx.mouseEnabled = true;
			this._italicTx.selectable = false;
			this._italicTx.htmlText = &quot;&lt;i&gt;Italic&lt;/i&gt;&quot;;
			this._italicTx.x = 10;
			this._italicTx.y = 200;
			this._italicTx.addEventListener(MouseEvent.CLICK, this.updateTextFormat);
			super.addChild(this._italicTx);
		}

		private function switchTextFontColor(event:MouseEvent):void
		{
			stage.focus = this._textField;
			this._textFormat.color = this.getColorByColorButton(event.currentTarget as Sprite);
		}

		private function changeHandler(event:Event):void
		{
			if (!this._textField.text.length) return;

			this._textField.setTextFormat(
				this._textFormat,
				this._textField.caretIndex -1 ,
				this._textField.caretIndex);
		}

		private function getColorByColorButton(dsp:DisplayObject):uint
		{
			switch(dsp)
			{
				case this._red	: return 0xFF0000;
				case this._blue	: return 0x0000FF;
				default			: return 0x000000;
			}
		}

		private function updateTextFormat(event:MouseEvent):void
		{
			stage.focus = this._textField;

			switch(event.target)
			{
				case this._boldTx 	: this._textFormat.bold = !this._textFormat.bold; break;
				case this._italicTx	: this._textFormat.italic = !this._textFormat.italic; break;
				default				: break;
			}

		}
	}
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=240&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/10/08/useful-actionscript-3-code-editing-textfield-using-settextformat/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>AS3 XML for Dummies</title>
		<link>http://ayumiloveflash.wordpress.com/2010/09/22/as3-xml-for-dummies/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/09/22/as3-xml-for-dummies/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 16:52:37 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=225</guid>
		<description><![CDATA[I&#8217;m not good in AS3 XML, so I trained myself to be proficient in this XML thingy so it doesn&#8217;t catch me off guard when I&#8217;m about to perform evil on it A Kirupan (andy310584) post a problem on setting each image position based on the category. Hello to everyone. let&#8217;s go straight to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=225&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not good in AS3 XML, so I trained myself to be proficient in this XML thingy so it doesn&#8217;t catch me off guard when I&#8217;m about to perform evil on it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a href="http://www.kirupa.com/forum/showthread.php?p=2575696#post2575696">A Kirupan (andy310584)</a> post a problem on setting each image position based on the category.</p>
<blockquote><p>Hello to everyone.<br />
let&#8217;s go straight to the problem.<br />
i have an xml that&#8217;s looks like this:</p></blockquote>
<pre class="brush: as3;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;pics&gt;
    &lt;category name=&quot;categoria1&quot;&gt;
        &lt;image NAME=&quot;1&quot; PATH=&quot;images/1.jpg&quot; DESCRIPTION=&quot;SALAM&quot;/&gt;
        &lt;image NAME=&quot;2&quot; PATH=&quot;images/2.jpg&quot; DESCRIPTION=&quot;SALAM2&quot;/&gt;
        &lt;image NAME=&quot;9&quot; PATH=&quot;images/3.jpg&quot; DESCRIPTION=&quot;SALAM3&quot;/&gt;
    &lt;/category&gt;
    &lt;category name=&quot;categoria2&quot;&gt;
        &lt;image NAME=&quot;3&quot; PATH=&quot;images/4.jpg&quot; DESCRIPTION=&quot;SALAM4&quot;/&gt;
        &lt;image NAME=&quot;4&quot; PATH=&quot;images/5.jpg&quot; DESCRIPTION=&quot;SALAM5&quot;/&gt;
        &lt;image NAME=&quot;5&quot; PATH=&quot;images/6.jpg&quot; DESCRIPTION=&quot;SALAM6&quot;/&gt;
        &lt;image NAME=&quot;5&quot; PATH=&quot;images/7.jpg&quot; DESCRIPTION=&quot;SALAM7&quot;/&gt;
    &lt;/category&gt;
    &lt;category name=&quot;categoria3&quot;&gt;
        &lt;image NAME=&quot;6&quot; PATH=&quot;images/8.jpg&quot; DESCRIPTION=&quot;SALAM8&quot;/&gt;
        &lt;image NAME=&quot;7&quot; PATH=&quot;images/9.jpg&quot; DESCRIPTION=&quot;SALAM9&quot;/&gt;
        &lt;image NAME=&quot;8&quot; PATH=&quot;images/10.jpg&quot; DESCRIPTION=&quot;SALAM10&quot;/&gt;
    &lt;/category&gt;
&lt;/pics&gt;
</pre>
<blockquote><p>As you can see i have categories and inside the categories i have the pictures. what i want to do is every category to be displayed with a lower y position than the previous category. and in every category the picture to be arrange in the way presented in the picture below (x position for images = 0, the picture is just to make an idea).</p>
<p>I know that i have to use for(i=0&#8230;.) and for(j=0&#8230;) but i can&#8217;t figure how. My AS3 code looks like this:</p></blockquote>
<pre class="brush: as3;">
import fl.transitions.Tween;
import fl.transitions.easing.*;

var _total:int = 0;
var _categories:XMLList = null;
var _subCategories:XMLList = null;
var _loaders:Array = new Array();
var _counter:int = 0;
var _next:int = 0;
var _tween:Tween = null;
var _container:Sprite = new Sprite();
var _text:TextField = new TextField();

var _loader:URLLoader = new URLLoader();
_loader.load(new URLRequest(&quot;gallery.xml&quot;));
_loader.addEventListener(Event.COMPLETE, Complete, false, 0, true);

function Complete(e:Event):void {
    var _xml:XML = new XML(e.target.data);

    _loader.removeEventListener(Event.COMPLETE, Complete);
    _loader = null;
    _categories = _xml.category;
    _total= _categories.length();

    LoadImages();
}

function LoadImages():void {
    for (var i:int = 0; i &lt; _total; i++) {
        var _url:String = _categories.image[i].@PATH;
        var _loader:Loader = new Loader();
        _loader.load(new URLRequest(_url));
        _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageLoaded);
        _loaders.push(_loader);
    }
}
</pre>
<p><font color="green"><br />
<h2>Solution</h2>
<p></font></p>
<pre class="brush: as3;">
trace(&quot;/////////////// Function4: ///////////////&quot;);

xml.category.(loadImageByCategory(@name,image.@PATH));

function loadImageByCategory(categoryId:String,xmllist:XMLList):void
{
	var yPos:int = this.getYPosByCategory(categoryId);
	this.loadImageWithYPos(yPos,xmllist);
}

function getYPosByCategory(categoryId:String):int
{
	switch(categoryId)
	{
		case &quot;categoria1&quot; : trace(&quot;Set image y:100&quot;); return 100;
		case &quot;categoria2&quot; : trace(&quot;Set image y:200&quot;); return 200;
		case &quot;categoria3&quot; : trace(&quot;Set image y:300&quot;); return 300;
		default: return 0;
	}
}

function loadImageWithYPos(yPos:int,xmllist:XMLList):void
{
	var l:int = xmllist.length();
	var i:int;

	for(i; i&lt;l; i++)
	{
		trace(&quot;yPos: &quot; + yPos + &quot; - Image Path: &quot; + xmllist[i]);
	}
}
</pre>
<p><font color="green"><br />
<h2>XML Traces</h2>
<p></font></p>
<pre class="brush: as3;">
/////////////// Function4: ///////////////
Set image y:100
yPos: 100 - Image Path: images/1.jpg
yPos: 100 - Image Path: images/2.jpg
yPos: 100 - Image Path: images/3.jpg
Set image y:200
yPos: 200 - Image Path: images/4.jpg
yPos: 200 - Image Path: images/5.jpg
yPos: 200 - Image Path: images/6.jpg
yPos: 200 - Image Path: images/7.jpg
Set image y:300
yPos: 300 - Image Path: images/8.jpg
yPos: 300 - Image Path: images/9.jpg
yPos: 300 - Image Path: images/10.jpg
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/225/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/225/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/225/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=225&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/09/22/as3-xml-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>RPG Element Formula</title>
		<link>http://ayumiloveflash.wordpress.com/2010/09/15/rpg-element-formula/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/09/15/rpg-element-formula/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 03:32:49 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=219</guid>
		<description><![CDATA[8 Elements Wind, Earth, Thunder, Water, Fire, Ice, Dark, Holy Effects Poison, Death, Doom, Syphon, Berserk, AccuracyDown, EvadeDown, MagicAttackDown, WeaponAttackDown Enemy weak against Earth receives extra damage from hero&#8217;s weapon earth element. Equipments are use to amplify/deamplify a value in hero similarly to Epic Battle Fantasy 3. Distribution Benefits 1 : 20% 2 : 40% [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=219&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>8 Elements</strong><br />
Wind, Earth, Thunder, Water, Fire, Ice, Dark, Holy</p>
<p><strong>Effects</strong><br />
Poison, Death, Doom, Syphon, Berserk, AccuracyDown, EvadeDown, MagicAttackDown, WeaponAttackDown</p>
<p>Enemy weak against Earth receives extra damage from hero&#8217;s<br />
weapon earth element.</p>
<p>Equipments are use to amplify/deamplify a value in hero similarly<br />
to Epic Battle Fantasy 3.</p>
<p>Distribution Benefits<br />
1 : 20%<br />
2 : 40%<br />
3 : 60%<br />
4 : 80%<br />
5 : 100%<br />
6 : 120%<br />
7 : 140%<br />
8 : 160%<br />
9 : 180%</p>
<p>Every specialty that an equipment has reduces 30% benefit.<br />
For instance:<br />
A weapon may cast an ice-element skill at 15% rate (-30%)<br />
A weapon may cast an ice-element skill at 30% rate (-60%)<br />
A weapon may cast an ice-element skill at 45% rate (-90%)</p>
<p>All entities has these stats (equipment as stat boosters)<br />
Health<br />
Magic<br />
Weapon Attack<br />
Weapon Defense<br />
Magic Attack<br />
Magic Defense<br />
Accuracy<br />
Evade</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/219/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=219&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/09/15/rpg-element-formula/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>ActionScript Error #5001: The name of package does not reflect the location of this file</title>
		<link>http://ayumiloveflash.wordpress.com/2010/09/14/actionscript-error-5001-the-name-of-package-does-not-reflect-the-location-of-this-file/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/09/14/actionscript-error-5001-the-name-of-package-does-not-reflect-the-location-of-this-file/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 03:31:03 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[ActionScript Error #5001]]></category>
		<category><![CDATA[adobe flash 5001 error]]></category>
		<category><![CDATA[does not reflect the location of this file]]></category>
		<category><![CDATA[The name of package]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=210</guid>
		<description><![CDATA[I bumped into this same error many times, so I decided to make a walkthrough for myself in case I forgot how to solve this problem Hope this helps you (reader) who are stuck in this error too. Below is the walkthrough on setting up your project packaging source path so you avoid that 5001 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=210&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I bumped into this same error many times,<br />
so I decided to make a walkthrough for myself<br />
in case I forgot how to solve this problem <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
Hope this helps you (reader) who are stuck in this error too.</p>
<p>Below is the walkthrough on setting up your project packaging<br />
source path so you avoid that 5001 error.</p>
<p>Assuming your project folder is located in your C drive C:\<br />
Let&#8217;s call it PackageTest folder for this scenario  C:\PackageTest<br />
Your fla is place inside  C:\PackageTest</p>
<p>Within the &#8216;PackageTest&#8217; folder contains a &#8216;com&#8217; folder<br />
The &#8216;com&#8217; folder contains another folder called &#8216;ayumilove&#8217;<br />
&#8216;ayumilove&#8217; folder contains the Game.as file</p>
<p>In short:<br />
c:\PackageTest\com\ayumilove\Game.as</p>
<p>Open Adobe Flash IDE (integrated development environment)<br />
and open up your .fla inside.</p>
<p>Go to File, Publish Settings, switch to Flash Tab and click Settings<br />
This pops a new window &#8216;Advanced ActionScript 3.0 Settings&#8217;</p>
<p>Switch to Source Path tab.<br />
Make sure the list has a dot .<br />
A dot represents the current location of the .fla that resides<br />
which is PackageTest. Adobe Flash will start looking into this<br />
location to search for the .as files.</p>
<p>However, our Game.as is located in com.ayumilove<br />
2 more folders deeper within PackageTest</p>
<p>So make sure that your .as class has that included in package name</p>
<pre class="brush: as3;">
package com.ayumilove
{
	import flash.display.MovieClip;

	public class Game extends MovieClip
	{

		public function Game()
		{
			trace(&quot;Game Created&quot;);
		}

	}

}
</pre>
<p>My Game.as will be the Main.as for the .fla<br />
So, returning back to the Adobe Flash Timeline,<br />
Open up your Properties Panel (CTRL+F3) or Windows, Properties<br />
Click on the stage, and set the class in Properties Panel as<br />
com.ayumilove.Game (NOT com.ayumilove.Game.as)</p>
<p>CTRL+ENTER to test the file. It works!</p>
<p>Extra notes:<br />
Assuming the location of both files are switched,<br />
meaning the Game.as now resides in the PackageTest<br />
and the .fla location now resides in PackageTest.com.ayumilove</p>
<p>You will need to use the double dot to move up 1 folder.<br />
To move up multiple folder, use the double dot syntax few times.</p>
<p>In your source path of your .fla would be<br />
../..<br />
This moves up from ayumilove to com<br />
and com to Package Test</p>
<p>If Game.as is located in another folder such as<br />
PackageTest/bin then it would now be<br />
../../bin</p>
<p>Extra notes again:</p>
<p>If in your Adobe Flash IDE, you set the source path<br />
as ./com/ayumilove and your .as file package name has<br />
package com.ayumilove, the compiler returns 5001 error too.</p>
<p>because what its trying to do is to search within<br />
PackageTest/com/ayumilove/com/ayumilove</p>
<p>To solve this, either change the source path as ./<br />
and keep the com.ayumilove in the package name of your .as</p>
<p>or</p>
<p>keep the ./com/ayumilove BUT remove the com.ayumilove<br />
from the package name within your .as class</p>
<p>MORE NOTES:-</p>
<p>If one of your movieclip/sprite/graphic or assets in the library<br />
is referenced to a class, make sure that it retains the path name<br />
too. </p>
<p>So for instance, I have a Red MovieClip in the library,<br />
and I have .as class separate from .fla which is located in<br />
com.ayumilove, </p>
<p>right-click on the movieclip, and click properties.<br />
Tick Export for actionscript<br />
Expord in frame 1<br />
and inside the class textbox, set it as com.ayumilove.Red<br />
The &#8216;Red&#8217; is the class name while com.ayumilove is the paackage<br />
name (path/location)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/210/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/210/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/210/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=210&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/09/14/actionscript-error-5001-the-name-of-package-does-not-reflect-the-location-of-this-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful Actionscript 3 Code: Dummies Guide to Getter Setter. Simple Explanation.</title>
		<link>http://ayumiloveflash.wordpress.com/2010/09/01/useful-actionscript-3-code-dummies-guide-to-getter-setter/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/09/01/useful-actionscript-3-code-dummies-guide-to-getter-setter/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 02:27:51 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=202</guid>
		<description><![CDATA[A fellow Kirupan (tpann) posted a question below: Very simple explanation of get/set? I read a lot about accessors or getters/setters, but to date I cannot really understand what they do. The language describing their use is just beyond my comprehension, not being any type of developer nor an advanced AS3 user. Can someone provide, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=202&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A fellow <a href="http://www.kirupa.com/forum/showthread.php?t=353582">Kirupan (tpann)</a> posted a question below:</p>
<p><font color="green"><br />
<h1>Very simple explanation of get/set?</h1>
<p></font></p>
<blockquote><p>
I read a lot about accessors or getters/setters, but to date I cannot really understand what they do. The language describing their use is just beyond my comprehension, not being any type of developer nor an advanced AS3 user.</p>
<p>Can someone provide, or point me in the direction of, a VERY SIMPLE getter/setter example that includes WHY it would be used as well as HOW to use it? I would really appreciate something small that doesn&#8217;t use just comments within functions (like &#8220;// here is where you do xyz&#8221;), but actual code (the actual doing of xyz). That way if I want to play with it and build on it I can.</p>
<p>Much appreciated!
</p></blockquote>
<p>It is very simple to comprehend!</p>
<p>First, you need to know&#8230;</p>
<p><font color="green"><br />
<h1>What is the purpose of getter/setter function?</h1>
<p></font><br />
As the name implies, getter means to get the value,<br />
setter means to set the value.</p>
<p>Getter and setter functions are special because they are &#8220;functions&#8221;<br />
but you do not need to add the () parentheses after it.</p>
<p>They look like a variable without the () , but they are actually functions.</p>
<p>They are commonly use when you need to:-<br />
(1) do some value manipulation before getting/setting the data.<br />
(2) do some checking before getting/setting the data.</p>
<p><font color="green"><br />
<h1>How do I apply getter/setter. Example please?</h1>
<p></font><br />
Below is an example (applied in a flash rpg game of mine)</p>
<p>Are you a RPG fan? If yes then this will be easy for you to digest.<br />
Let&#8217;s say to calculate a hero&#8217;s bare-hand punching damage, its affected by 4 attributes:<br />
- strength<br />
- dexterity<br />
- intelligence<br />
- luck</p>
<p>You don&#8217;t store the damage in a variable!<br />
Remember, it&#8217;s based on the 4 attributes above.</p>
<p>The below scenario, you use getter to get the manipulate damage value.<br />
However, you can&#8217;t use setter because damage isn&#8217;t a variable</p>
<pre class="brush: as3; wrap-lines: false;">
package
{

    public class Hero extends Object
    {
        private var _strength:uint;
        private var _dexterity:uint;
        private var _intelligence:uint;
        private var _luck:uint;

        public function Formula() { super(); }

        public function get damage():uint
        {
            var damage:uint;
            damage += 4 * this._strength;
            damage += 3 * this._dexterity;
            damage += 2 * this._intelligence;
            damage += 1 * this._luck;
            return damage;
        }
    }
}
</pre>
<p>Now, how about applying both getter and setter?<br />
Let&#8217;s take a RPG (role-playing-game) bank example.<br />
This time we use a variable to store the data.</p>
<p>Note: The variable name must be different than the getter/setter name.<br />
You can&#8217;t use a variable name &#8216;money&#8217; and the function name &#8216;money&#8217;.<br />
This will cause Actionscript 3 naming error. To avoid it, the money variable<br />
is set to either private/protected with an underscore prefixed.</p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package
{
    public class Bank extends Object
    {
        private var _money:uint;

        public function Bank() { super(); }

        public function get money():uint
        {
            return this._money;
        }

        public function set money(value:int):void
        {
            this._money = value;
            if (this._money &gt; 100) this._money = 100;
        }
    }
}

//Demo to test our bank!
package
{
    public class Main extends Object
    {
        private var _money:uint;

        public function Main()
        {
            super();
            var bank:Bank = new Bank();
            trace(bank.money); //traces 0; (before)
            bank.money += 200;
            trace(bank.money); //traces 100; (after)
        }

    }
}
</pre>
<p>As you can see above, the setter did some money manipulation,<br />
which is , if the value banked in is greater than the maximum capacity,<br />
then ignore the rest and store a maximum of 100.</p>
<p>This can be applied to other scenario such as health (HP)<br />
whereby your health is sitting at 30/100 and you drank<br />
a health potion that heals 200 HP, but your current HP<br />
will not heal above 100. It becomes 100/100. Understand?</p>
<pre class="brush: as3; wrap-lines: false;">
bank.money += 200;
</pre>
<p>The code snippet above looks simple and elegant,<br />
but does lots of things, lets break this down!</p>
<pre class="brush: as3; wrap-lines: false;">
bank.money += 200;
// is similar to...
bank.money = bank.money + 200;
//(setter money) = (getter money) + 200;
</pre>
<p>When you write like the above, its telling to the Flash<br />
to get the money from the bank (getter function) and add 200 to it.</p>
<p>Finally, the sum of bank.money (getter function) + 200<br />
is stored back into bank.money (setter function)</p>
<p><font color="green"><br />
<h1>So when do I use getter setter?</h1>
<p></font><br />
Use getter/setter when you need to do manipulation to the value.</p>
<p>Some developers simply set their variables to private and add<br />
the getter/setter functions. So in the future, if they need to manipulate<br />
the data or check the data, they can write into the getter/setter.</p>
<p>Some developer mixed them, which is having public variables for<br />
those data that does not need manipulation, and have private variables<br />
with getter/setter when those data needed to be manipulated.</p>
<p>About the performance issue, accessing a public variable is much faster<br />
than calling a function. Since getter/setter functions are special a little,<br />
they have less performance overhead compare to a normal function that<br />
is called. You can do a speed performance benchmark on those 3<br />
accessing (public variables) vs (getter/setter) vs (normal functions).</p>
<p>If you are into PHP coding or some programming language that<br />
does not support getter/setter, you will normally see a person doing this&#8230;</p>
<pre class="brush: as3; wrap-lines: false;">
function getValueOfFruit()
{
return $fruitPrice;
}
</pre>
<p>Oh yeah, I just remembered something&#8230;</p>
<p>You avoid getter/setter functions when your function parameter has more than 1.</p>
<p>For instance:-</p>
<pre class="brush: as3; wrap-lines: false;">
function getFruitPrice(fruitGrade,fruitAmount):void
{
return fruitGrade * fruitAmount;
}
</pre>
<p>Last but not least, it is not necessary to have both getter and setter together. They are independent! It means that you can have only getter without a setter (like the first example shown above), you code can have setter without getter (the opposite) or you can have both of them.</p>
<p>Talking about having setter without getter,<br />
you can establish a few setter functions for the 4 attributes:<br />
strength, dexterity, intelligence and luck.<br />
But those 4 attributes does not need getter functions.</p>
<p>If you (the client) only wants damage by inputting values into those attributes, it would be :-<br />
(1) setters for the 4 attributes<br />
(2) getters for the damage attribute.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/202/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/202/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/202/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=202&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/09/01/useful-actionscript-3-code-dummies-guide-to-getter-setter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful Actionscrip 3 Code: Dummies Guide to Getter/Setter Function</title>
		<link>http://ayumiloveflash.wordpress.com/2010/09/01/useful-actionscrip-3-code-dummies-guide-to-gettersetter-function/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/09/01/useful-actionscrip-3-code-dummies-guide-to-gettersetter-function/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 02:20:39 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=200</guid>
		<description><![CDATA[it&#8217;s very simple to comprehend First, you need to know&#8230; [SIZE=4][COLOR=Red][B]What is the purpose of getter/setter function?[/B][/COLOR][/SIZE] As the name implies, getter means to get the value, setter means to set the value. Getter and setter functions are special because they are &#8220;functions&#8221; but you do not need to add the () parentheses after it. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=200&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>it&#8217;s very simple to comprehend <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>First, you need to know&#8230;</p>
<p>[SIZE=4][COLOR=Red][B]What is the purpose of getter/setter function?[/B][/COLOR][/SIZE]<br />
As the name implies, getter means to get the value,<br />
setter means to set the value.</p>
<p>Getter and setter functions are special because they are &#8220;functions&#8221;<br />
but you do not need to add the () parentheses after it.</p>
<p>They look like a variable without the () , but they are actually functions.</p>
<p>They are commonly use when you need to:-<br />
(1) do some value manipulation before getting/setting the data.<br />
(2) do some checking before getting/setting the data.</p>
<p>[B][SIZE=4][COLOR=Red]<br />
How do I apply getter/setter. Example please?<br />
[/COLOR][/SIZE][/B]Below is an example (applied in a flash rpg game of mine)</p>
<p>Are you a RPG fan? If yes then this will be easy for you to digest.<br />
Let&#8217;s say to calculate a hero&#8217;s bare-hand punching damage, its affected by 4 attributes:<br />
- strength<br />
- dexterity<br />
- intelligence<br />
- luck</p>
<p>You don&#8217;t store the damage in a variable!<br />
Remember, it&#8217;s based on the 4 attributes above.</p>
<p>The below scenario, you use getter to get the manipulate damage value.<br />
However, you can&#8217;t use setter because damage isn&#8217;t a variable <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
[PHP]<br />
package<br />
{</p>
<p>    public class Hero extends Object<br />
    {<br />
        private var _strength:uint;<br />
        private var _dexterity:uint;<br />
        private var _intelligence:uint;<br />
        private var _luck:uint;</p>
<p>        public function Formula() { super(); }</p>
<p>        public function get damage():uint<br />
        {<br />
            var damage:uint;<br />
            damage += 4 * this._strength;<br />
            damage += 3 * this._dexterity;<br />
            damage += 2 * this._intelligence;<br />
            damage += 1 * this._luck;<br />
            return damage;<br />
        }<br />
    }<br />
}<br />
[/PHP]Now, how about applying both getter and setter?<br />
Let&#8217;s take a RPG (role-playing-game) bank example.<br />
This time we use a variable to store the data.</p>
<p>Note: The variable name must be different than the getter/setter name.<br />
You can&#8217;t use a variable name &#8216;money&#8217; and the function name &#8216;money&#8217;.<br />
This will cause Actionscript  3 naming error. To avoid it, the money variable<br />
is set to either private/protected with an underscore prefixed.</p>
<p>[PHP]<br />
/**<br />
* &#8230;<br />
* @author ayumilove<br />
*/</p>
<p>package<br />
{<br />
    public class Bank extends Object<br />
    {<br />
        private var _money:uint;</p>
<p>        public function Bank() { super(); }</p>
<p>        public function get money():uint<br />
        {<br />
            return this._money;<br />
        }</p>
<p>        public function set money(value:int):void<br />
        {<br />
            this._money = value;<br />
            if (this._money &gt; 100) this._money = 100;<br />
        }<br />
    }<br />
}</p>
<p>//Demo to test our bank!<br />
package<br />
{<br />
    public class Main extends Object<br />
    {<br />
        private var _money:uint;</p>
<p>        public function Main()<br />
        {<br />
            super();<br />
            var bank:Bank = new Bank();<br />
            trace(bank.money); //traces 0; (before)<br />
            bank.money += 200;<br />
            trace(bank.money); //traces 100; (after)<br />
        }</p>
<p>    }<br />
}<br />
[/PHP]As you can see above,<br />
the setter did some money manipulation,<br />
which is , if the value banked in is greater than the maximum capacity,<br />
then ignore the rest and store a maximum of 100.</p>
<p>This can be applied to other scenario such as health (HP)<br />
whereby your health is sitting at 30/100 and you drank<br />
a health potion that heals 200 HP, but your current HP<br />
will not heal above 100. It becomes 100/100. Understand?</p>
<p>[PHP]<br />
bank.money += 200;<br />
[/PHP]The code snippet above looks simple and elegant,<br />
but does lots of things, lets break this down!</p>
<p>[PHP]<br />
bank.money += 200;<br />
// is similar to&#8230;<br />
bank.money = bank.money + 200;<br />
//[setter money] = [getter money] + 200;<br />
[/PHP]When you write like the above, its telling to the Flash<br />
to get the money from the bank (getter function) and add 200 to it.</p>
<p>Finally, the sum of bank.money (getter function) + 200<br />
is stored back into bank.money (setter function)</p>
<p>[B][SIZE=4][COLOR=Red]So when do I use getter setter?<br />
[/COLOR][/SIZE][/B]Use getter/setter when you need to do manipulation to the value.</p>
<p>Some developers simply set their variables to private and add<br />
the getter/setter functions. So in the future, if they need to manipulate<br />
the data or check the data, they can write into the getter/setter.</p>
<p>Some developer mixed them, which is having public variables for<br />
those data that does not need manipulation, and have private variables<br />
with getter/setter when those data needed to be manipulated.</p>
<p>About the performance issue, accessing a public variable is much faster<br />
than calling a function. Since getter/setter functions are special a little,<br />
they have less performance overhead compare to a normal function that<br />
is called. You can do a speed performance benchmark on those 3<br />
accessing (public variables) vs (getter/setter) vs (normal functions).</p>
<p>If you are into PHP coding or some programming language that<br />
does not support getter/setter, you will normally see a person doing this&#8230;<br />
[PHP]<br />
function getValueOfFruit()<br />
{<br />
return $fruitPrice;<br />
}<br />
[/PHP]Oh yeah, I just remembered something&#8230;</p>
<p>You avoid getter/setter functions when your function parameter has more than 1.</p>
<p>For instance:-<br />
[PHP]<br />
function getFruitPrice(fruitGrade,fruitAmount):void<br />
{<br />
return fruitGrade * fruitAmount;<br />
}<br />
[/PHP]</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=200&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/09/01/useful-actionscrip-3-code-dummies-guide-to-gettersetter-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful Actionscript 3 Code: Handle Last Called Function</title>
		<link>http://ayumiloveflash.wordpress.com/2010/08/31/useful-actionscript-3-code-handle-last-called-function/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/08/31/useful-actionscript-3-code-handle-last-called-function/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 17:31:17 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=194</guid>
		<description><![CDATA[A fellow Kirupan (darastudio) posted a question below: Odd if statement/varialbles question? I wasn&#8217;t even sure how to search to see if this existed. Say I have a list (array) of functions s_0, s_1, s_2, etc&#8230;. probably going to be 30 or so in the list. Is there a way to do an if statement [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=194&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A fellow <a href="http://www.kirupa.com/forum/showthread.php?t=353564">Kirupan (darastudio)</a> posted a question below:</p>
<blockquote><p> Odd if statement/varialbles question?<br />
I wasn&#8217;t even sure how to search to see if this existed.</p>
<p>Say I have a list (array) of functions<br />
s_0, s_1, s_2, etc&#8230;. probably going to be 30 or so in the list.</p>
<p>Is there a way to do an if statement so that&#8230;</p>
<p>if the last function == s_0 &#8230; do this thing<br />
else the last function == s_2 &#8230; do this other thing</p>
<p>i&#8217;m basically doing a linear presentation of functions<br />
and i need the ability to go foward and backwards&#8230; but the animations/functions may be different depending on the direction, up or down in the list.</p>
<p>Help? </p></blockquote>
<p><font color="green"><strong>Below is a short sweet solution:</strong></font><br />
Copy and paste the code in your Flash IDE to test it out.</p>
<pre class="brush: as3; wrap-lines: false;">
//3 global variables (private)
var lastCalledFunction:Function ;
var askFunctions:Array = [askApplePrice,askOrangePrice,askPearPrice];
var replyFunctions:Array = [replyApplePrice,replyOrangePrice,replyPearPrice];

//Sample Functions (Each 'reply' functions handles one particular 'ask' function)
function askApplePrice():void { trace(&quot;How much is an apple?&quot;); }
function askOrangePrice():void { trace(&quot;How much is an orange?&quot;);}
function askPearPrice():void { trace(&quot;How much is a pear?&quot;); }

function replyApplePrice():void { trace(&quot;Apple costs $1&quot;); }
function replyOrangePrice():void { trace(&quot;Orange costs $1&quot;); }
function replyPearPrice():void { trace(&quot;Pear costs $1&quot;); }

//Business logic
function handleAskReply():void
{
	var i:int = this.askFunctions.indexOf(this.lastCalledFunction);
	if(i&lt;0) return;
	this.replyFunctions[i]();
}

//Demo:
var randomIndex:uint = Math.random() * this.askFunctions.length;
this.lastCalledFunction = this.askFunctions[randomIndex];
this.lastCalledFunction();
this.handleAskReply();
</pre>
<p><strong>Result / Traces</strong></p>
<p>How much is an apple?<br />
Apple costs $1</p>
<p>How much is an orange?<br />
Orange costs $1</p>
<p>How much is a pear?<br />
Pear costs $1</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/194/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/194/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/194/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=194&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/08/31/useful-actionscript-3-code-handle-last-called-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful ActionScript 3 Code: RPG Stat System (Role Playing Game)</title>
		<link>http://ayumiloveflash.wordpress.com/2010/08/29/useful-actionscript-3-code-rpg-stat-system-role-playing-game/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/08/29/useful-actionscript-3-code-rpg-stat-system-role-playing-game/#comments</comments>
		<pubDate>Sun, 29 Aug 2010 07:38:21 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=172</guid>
		<description><![CDATA[Below is a stat system that can be applied into any games that uses stat. Stat is known as attribute. RPG games commonly introduces stat in their games. Games such as Final Fantasy, World of Warcraft, MapleStory, Ragnarok, Mafia Wars uses health, mana, magic, energy, strength, dexterity, luck, intellect as their stat. The TestStat.as class [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=172&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Below is a stat system that can be applied into any games that<br />
uses stat. Stat is known as attribute. RPG games commonly<br />
introduces stat in their games. Games such as Final Fantasy,<br />
World of Warcraft, MapleStory, Ragnarok, Mafia Wars uses<br />
health, mana, magic, energy, strength, dexterity, luck, intellect<br />
as their stat.</p>
<p>The TestStat.as class is to demonstrate on how to use this<br />
stat system. The example below is about a hero&#8217;s health<br />
which is manipulated by equipment and skill.<br />
- Timeless Ring (Equipment)<br />
- Hyperbody (Skill)<br />
- Epic Armor (Equipment)</p>
<p><strong>Stats Input: Stack and Priority</strong><br />
The stat system uses stack to determine whether an<br />
equipment or skill is able to stack multiple times.<br />
The stat system also uses priority to determine the order of<br />
modifier being executed. Priority with the biggest value starts<br />
first. Priority can be either negative or positive value.</p>
<p><strong>Explanation</strong><br />
Assuming that any equipment is equipped, the hero gains<br />
bonus stat. Timeless Ring provides the hero +50 Health.<br />
In the TestStat.as Class, the stack is set as true.<br />
This means, whenever the hero wears another duplicate<br />
equipment (a second Timeless Ring) the bonus stacks.<br />
In short, 30 (base health) + 50 (ring health) +50 (ring health).</p>
<p>While skill such as Hyperbody isn&#8217;t stackable (as demonstrated<br />
in the TestStat.as where stack is false). This skill temporarily<br />
raises hero&#8217;s health by 160% health. However, if hero attempts<br />
to cast Hyperbody Skill twice or more), the skill bonus stat does<br />
not stack (does not have any effect) It will be always 160%.</p>
<p>Epic Armor has a priority of zero, which means it will be<br />
executed last. 148 health from rings and hyperbody is doubled,<br />
resulting 296 health in total (modified total health).</p>
<p><font color="green"><br />
<h1>Credits</h1>
<p></font><br />
If you use the code below, please credit me by posting the link<br />
in your source code <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><font color="green"><br />
<h1>TestStat.as</h1>
<p></font></p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package com.stat
{

	public class TestStat extends Object
	{
		//----------------------------------------------------------------------
		//
		//  Constructor
		//
		//----------------------------------------------------------------------

		public function TestStat ()
		{
			super (); 

			var statId:String = &quot;Health&quot;;
			var stats : Stats = new Stats();
			stats.addStat(&quot;Health&quot;, 10, 30);

			trace(&quot;Initial Health without any modifiers&quot;);
			stats.traceStat(statId);

			trace(&quot;Modify By Adding 50 Health (Timeless Ring) 1st&quot;);
			stats.addAdditionModifierToStat
			(&quot;Health&quot;, &quot;Timeless Ring&quot;, 50, true, 1);
			stats.traceStat(statId);

			trace(&quot;Modify By Adding 50 Health (Timeless Ring) 2nd&quot;);
			stats.addAdditionModifierToStat
			(&quot;Health&quot;, &quot;Timeless Ring&quot;, 50, true, 1);
			stats.traceStat(statId);

			trace(&quot;Modify By Multiplying 160% Health (Hyperbody Skill) 1st&quot;);
			stats.addMultiplyModifierToStat
			(&quot;Health&quot;, &quot;Hyperbody&quot;, 1.6, false, 2);
			stats.traceStat(statId);

			trace(&quot;Modify By Multiplying 160% Health (Hyperbody Skill) 2nd&quot;);
			stats.addMultiplyModifierToStat
			(&quot;Health&quot;, &quot;Hyperbody&quot;, 1.6, false, 2);
			stats.traceStat(statId);

			trace(&quot;Modify By Multiplying 200% Health (Epic Armor)&quot;);
			stats.addMultiplyModifierToStat
			(&quot;Health&quot;, &quot;Epic Armor&quot;, 2, false, 0);
			stats.traceStat(statId);

			trace(&quot;Modify By Adding 200% To Current Health (Health Elixir)&quot;);
			stats.setStatCurrentValue
			(&quot;Health&quot;, stats.getStatTotalValueModified(&quot;Health&quot;) * 2);
			stats.traceStat(statId);
		}

	}
}
</pre>
<p><strong>Traces:-</strong></p>
<pre class="brush: plain;">
Initial Health without any modifiers
Current Health: 10
Total Health (Unmodified): 30
Total Health (Modified): 30

Modify By Adding 50 Health (Timeless Ring) 1st
Current Health: 10
Total Health (Unmodified): 30
Total Health (Modified): 80

Modify By Adding 50 Health (Timeless Ring) 2nd
Current Health: 10
Total Health (Unmodified): 30
Total Health (Modified): 130

Modify By Multiplying 160% Health (Hyperbody Skill) 1st
Current Health: 10
Total Health (Unmodified): 30
Total Health (Modified): 148

Modify By Multiplying 160% Health (Hyperbody Skill) 2nd
Current Health: 10
Total Health (Unmodified): 30
Total Health (Modified): 148

Modify By Multiplying 200% Health (Epic Armor)
Current Health: 10
Total Health (Unmodified): 30
Total Health (Modified): 296

Modify By Adding 200% To Current Health (Health Elixir)
Current Health: 296
Total Health (Unmodified): 30
Total Health (Modified): 296
</pre>
<p><font color="green"><br />
<h1>Stats.as</h1>
<p></font></p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package com.stat
{

	public class Stats extends Object
	{
		//----------------------------------------------------------------------
		//
		//  Private properties
		//
		//----------------------------------------------------------------------

		private var _stats:Object = { };

		//----------------------------------------------------------------------
		//
		//  Constructor
		//
		//----------------------------------------------------------------------

		public function Stats() { super(); }

		//----------------------------------------------------------------------
		//
		//  Add/Remove Stats
		//
		//----------------------------------------------------------------------

		public function addStat(statId:String,current:Number,total:Number):void
		{
			if (this._stats[statId]) return;
			var stat:Stat = new Stat();
			stat.id = statId;
			stat.current = current;
			stat.totalUnmodified = total;
			this._stats[statId] = stat;
		}

		public function removeStat(statId:String):void
		{
			if (!this._stats[statId]) return;
			this._stats[statId] = null;
			delete this._stats[statId];
		}

		//----------------------------------------------------------------------
		//
		//  Get/Set Value (Current and Total)
		//
		//----------------------------------------------------------------------

		public function getStatCurrentValue(statId:String):Number
		{
			if (!this._stats[statId]) return 0;
			var stat:Stat = this._stats[statId];
			return stat.current;
		}

		public function setStatCurrentValue(statId:String,value:Number):void
		{
			if (!this._stats[statId]) return ;
			var stat:Stat = this._stats[statId];
			stat.current = value;
		}

		public function getStatTotalValueUnmodified(statId:String):Number
		{
			if (!this._stats[statId]) return 0;
			var stat:Stat = this._stats[statId];
			return stat.totalUnmodified;
		}

		public function setStatTotalValueUnmodified(statId:String,value:Number):void
		{
			if (!this._stats[statId]) return ;
			var stat:Stat = this._stats[statId];
			stat.totalUnmodified = value;
		}

		public function getStatTotalValueModified(statId:String):Number
		{
			if (!this._stats[statId]) return 0;
			var stat:Stat = this._stats[statId];
			return stat.totalModified;
		}

		//----------------------------------------------------------------------
		//
		//  Add/Remove Modifier
		//
		//----------------------------------------------------------------------

		public function addAdditionModifierToStat(
		statId:String, modifierId:String, value:Number,
		stackable:Boolean = true, priority:int = 0):void
		{
			var modifier:Modifier = new AdditionModifier();
			this.setModifierToStat(
			statId,modifier,modifierId,value,stackable,priority);
		}

		public function addMultiplyModifierToStat(
		statId:String, modifierId:String, value:Number,
		stackable:Boolean = true, priority:int = 0):void
		{
			var modifier:Modifier = new MultiplyModifier();
			this.setModifierToStat(
			statId,modifier,modifierId,value,stackable,priority);
		}

		public function removeModifierFromStat(
		statId:String, modifierId:String):void
		{
			if (!this._stats[statId]) return;
			var stat:Stat = this._stats[statId];
			stat.removeModifier(modifierId);
		}

		//----------------------------------------------------------------------
		//
		//  Helper Methods
		//
		//----------------------------------------------------------------------

		private function setModifierToStat(
		statId:String, modifier:Modifier, modifierId:String, value:Number,
		stackable:Boolean, priority:int):void
		{
			if (!this._stats[statId]) return;
			var stat:Stat = this._stats[statId];
			modifier.id = modifierId;
			modifier.value = value;
			modifier.stackable = stackable;
			modifier.priority = priority;
			stat.addModifier(modifier);
		}

		public function traceStat(statId:String):void
		{
			if (!this._stats[statId]) return;

			trace(&quot;Current &quot; + statId + &quot;: &quot; +
			this.getStatCurrentValue(statId));

			trace(&quot;Total &quot; + statId + &quot; (Unmodified): &quot; +
			this.getStatTotalValueUnmodified(statId));

			trace(&quot;Total &quot; + statId + &quot; (Modified): &quot; +
			this.getStatTotalValueModified(statId));

			trace(&quot;&quot;);
		}

	}
}
</pre>
<p><font color="green"><br />
<h1>Stat.as</h1>
<p></font></p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package com.stat
{

	public class Stat extends Object
	{
		//----------------------------------------------------------------------
		//
		//  Public properties
		//
		//----------------------------------------------------------------------

		public function get id():String
		{
			return this._id;
		}

		public function set id(value:String):void
		{
			this._id = value;
		}

		public function get current():Number
		{
			return this._current;
		 }

		public function set current(value:Number):void
		{
			this._current = value;

			if (this._current &gt; this._totalModified)
			{
				this._current = this._totalModified;
			}
		}

		public function get totalModified():Number
		{
			return this._totalModified;
		}

		public function get totalUnmodified():Number
		{
			return this._totalUnmodified;
		}

		public function set totalUnmodified(value:Number):void
		{
			this._totalUnmodified = value;
			this.updateTotalModified();
		}

		//----------------------------------------------------------------------
		//
		//  Private properties
		//
		//----------------------------------------------------------------------

		private var _id:String = &quot;&quot;;
		private var _current:Number = 0;
		private var _totalModified:Number = 0;
		private var _totalUnmodified:Number = 0;
		private var _modifiers:Object = { };

		//----------------------------------------------------------------------
		//
		//  Constructor
		//
		//----------------------------------------------------------------------

		public function Stat() { super(); }

		//----------------------------------------------------------------------
		//
		//  Add/Remove/Update Modifier
		//
		//----------------------------------------------------------------------

		public function addModifier(modifier:Modifier):void
		{
			if (!this._modifiers[modifier.id])
			{
				this._modifiers[modifier.id] = modifier;
			}
			else
			{
				modifier = this._modifiers[modifier.id];
				if (modifier.stackable) { modifier.stack++; }
			}

			this.updateTotalModified();
		}

		public function removeModifier(modifierId:String):void
		{
			var modifier:Modifier = this._modifiers[modifierId];

			if (modifier)
			{
				modifier.stack--;
				if (modifier.stack &lt; 1)
				{
					this._modifiers[modifierId] = null;
					delete this._modifiers[modifierId];
				}
			}
			this.updateTotalModified();
		}

		private function updateTotalModified():void
		{
			this._totalModified = this._totalUnmodified;
			var modifiers:Array = [];

			for (var property:String in this._modifiers)
			{
				modifiers.push(this._modifiers[property]);
			}

			modifiers.sortOn(&quot;priority&quot;, Array.NUMERIC);

			var modifier:Modifier;
			var i:int = modifiers.length;

			while (i--)
			{
				modifier = modifiers[i];
				this._totalModified = modifier.modify(this._totalModified);
			}

		}

	}
}
</pre>
<p><font color="green"><br />
<h1>Modifier</h1>
<p></font></p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package com.stat
{

	public class Modifier extends Object
	{
		//----------------------------------------------------------------------
		//
		//  Public properties
		//
		//----------------------------------------------------------------------

		public function get id():String
		{
			return this._id;
		}

		public function set id(value:String):void
		{
			this._id = value;
		}

		public function get value():Number
		{
			return this._value;
		}

		public function set value(value:Number):void
		{
			this._value = value;
		}

		public function get stack():Number
		{
			return this._stack;
		}

		public function set stack(value:Number):void
		{
			this._stack = value;
		}

		public function get stackable():Boolean
		{
			return this._stackable;
		}

		public function set stackable(value:Boolean):void
		{
			this._stackable = value;
		}

		public function get priority():int
		{
			return this._priority;
		}

		public function set priority(value:int):void
		{
			this._priority = value;
		}

		//----------------------------------------------------------------------
		//
		//  Protected properties
		//
		//----------------------------------------------------------------------

		protected var _id:String = &quot;&quot;;
		protected var _value:Number = 0;
		protected var _stack:Number = 1;
		protected var _stackable:Boolean;
		protected var _priority:int;

		//----------------------------------------------------------------------
		//
		//  Constructor
		//
		//----------------------------------------------------------------------

		public function Modifier() { super(); }

		//----------------------------------------------------------------------
		//
		//  Public methods
		//
		//----------------------------------------------------------------------

		public function modify(value:Number):Number
		{
			return value;
		}

	}
}
</pre>
<p><font color="green"><br />
<h1>AdditionModifier.as</h1>
<p></font></p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package com.stat
{

	public class AdditionModifier extends Modifier
	{
		//----------------------------------------------------------------------
		//
		//  Constructor
		//
		//----------------------------------------------------------------------

		public function AdditionModifier() { super(); }

		//----------------------------------------------------------------------
		//
		//  Public methods
		//
		//----------------------------------------------------------------------

		public override function modify(value:Number):Number
		{
			value += super._value * stack;
			return value;
		}

	}
}
</pre>
<p><font color="green"><br />
<h1>MultiplyModifier.as</h1>
<p></font></p>
<pre class="brush: as3; wrap-lines: false;">
/**
* ...
* @author ayumilove
*/

package com.stat
{

	public class MultiplyModifier extends Modifier
	{
		//----------------------------------------------------------------------
		//
		//  Constructor
		//
		//----------------------------------------------------------------------

		public function MultiplyModifier() { super(); }

		//----------------------------------------------------------------------
		//
		//  Public methods
		//
		//----------------------------------------------------------------------

		public override function modify(value:Number):Number
		{
			value *= super._value * stack;
			return value;
		}

	}
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/172/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/172/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/172/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=172&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/08/29/useful-actionscript-3-code-rpg-stat-system-role-playing-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful ActionScript 3 Code: Dynamic Object Instance Name</title>
		<link>http://ayumiloveflash.wordpress.com/2010/08/28/useful-actionscript-3-code-dynamic-object-instance-name/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/08/28/useful-actionscript-3-code-dynamic-object-instance-name/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 14:20:43 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=169</guid>
		<description><![CDATA[There are 2 ways of looping variables: The first way is to store those 3 textfields into an array, and loop. The second way is the one below. Instead of storing them into an array, I loop them by having a dynamic variable beside the textField this["textField"+i] import flash.text.TextField; var ayumiloveMessage:Array = [&#34;welcome to&#34;,&#34;ayumilove&#34;,&#34;world&#34;]; var [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=169&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are 2 ways of looping variables:<br />
The first way is to store those 3 textfields into an array, and loop.<br />
The second way is the one below.<br />
Instead of storing them into an array,<br />
I loop them by having a dynamic variable beside the textField<br />
this["textField"+i]</p>
<pre class="brush: as3; wrap-lines: false;">
import flash.text.TextField;

var ayumiloveMessage:Array = [&quot;welcome to&quot;,&quot;ayumilove&quot;,&quot;world&quot;];

var textField1:TextField = new TextField();
var textField2:TextField = new TextField();
var textField3:TextField = new TextField();

textField1.y = 0;
textField2.y = 30;
textField3.y = 60;

super.addChild(textField1);
super.addChild(textField2);
super.addChild(textField3);

for(var i:int=0; i &lt; ayumiloveMessage.length; i++)
{
	this[&quot;textField&quot;+(i+1)].text = ayumiloveMessage[i];
}
</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=169&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/08/28/useful-actionscript-3-code-dynamic-object-instance-name/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
		<item>
		<title>Useful ActionScript 3 Code : Controlling Sprite Movement Left, Right, Up, Down, Diagonal</title>
		<link>http://ayumiloveflash.wordpress.com/2010/08/28/useful-actionscript-3-code-controlling-sprite-movement-left-right-up-down-diagonal/</link>
		<comments>http://ayumiloveflash.wordpress.com/2010/08/28/useful-actionscript-3-code-controlling-sprite-movement-left-right-up-down-diagonal/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 11:49:36 +0000</pubDate>
		<dc:creator>ayumilove</dc:creator>
				<category><![CDATA[ActionScript3]]></category>

		<guid isPermaLink="false">http://ayumiloveflash.wordpress.com/?p=165</guid>
		<description><![CDATA[Controlling Sprite Movement in ActionScript 3 The code below prevents a user from moving diagonal. The sprite is constricted to move only left,right, up and down at any point of time. This is to address a fellow Kirupan issue in this thread. import flash.display.Sprite; import flash.events.KeyboardEvent; var speed:uint = 10; var keyLock:uint; var sp:Sprite = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=165&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><font color="green"><br />
<h1>Controlling Sprite Movement in ActionScript 3</h1>
<p></font></p>
<p>The code below prevents a user from moving diagonal.<br />
The sprite is constricted to move only left,right, up and down<br />
at any point of time. This is to address a fellow <a href="http://www.kirupa.com/forum/showthread.php?t=353429">Kirupan issue<br />
in this thread.</a></p>
<pre class="brush: as3; wrap-lines: false;">
import flash.display.Sprite;
import flash.events.KeyboardEvent;

var speed:uint = 10;
var keyLock:uint;

var sp:Sprite = new Sprite();
sp.graphics.beginFill(0xFF0000);
sp.graphics.drawRect(0,0,25,25);
sp.graphics.endFill();
super.addChild(sp);

super.stage.addEventListener(KeyboardEvent.KEY_DOWN, this.keyDownHandler);

function keyDownHandler(event:KeyboardEvent):void
{
	switch(event.keyCode)
	{
		case Keyboard.LEFT 	: sp.x -= this.speed; break;
		case Keyboard.RIGHT : sp.x += this.speed; break;
		case Keyboard.UP 	: sp.y -= this.speed; break;
		case Keyboard.DOWN 	: sp.y += this.speed; break;
		default 			: break;
	}
}
</pre>
<p>Preview SWF Here<br />
<a href="http://megaswf.com/serve/41252/">http://megaswf.com/serve/41252/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ayumiloveflash.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ayumiloveflash.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/ayumiloveflash.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/ayumiloveflash.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ayumiloveflash.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ayumiloveflash.wordpress.com/165/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ayumiloveflash.wordpress.com/165/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ayumiloveflash.wordpress.com/165/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ayumiloveflash.wordpress.com&amp;blog=5368797&amp;post=165&amp;subd=ayumiloveflash&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://ayumiloveflash.wordpress.com/2010/08/28/useful-actionscript-3-code-controlling-sprite-movement-left-right-up-down-diagonal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8e34a54ace05ca27323a1aceeb923bd0?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ayumilove</media:title>
		</media:content>
	</item>
	</channel>
</rss>
