<?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/"
	>

<channel>
	<title>Anna Filina &#187; as3</title>
	<atom:link href="http://annafilina.com/blog/tag/as3/feed/" rel="self" type="application/rss+xml" />
	<link>http://annafilina.com/blog</link>
	<description>Web applications developer, conference organizer, geek...</description>
	<lastBuildDate>Mon, 31 May 2010 21:39:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Simplify camera parameters in pv3d</title>
		<link>http://annafilina.com/blog/camera-param-in-pv3d/</link>
		<comments>http://annafilina.com/blog/camera-param-in-pv3d/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 21:10:38 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[papervision3d]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=346</guid>
		<description><![CDATA[I&#8217;ve been supplied a 2D sketch of what my 3D world (PaperVision3D) will look like. The hardest part was matching the perspective by carefully positioning the camera. Having no other way than trial and error and a total of 7 different parameters, I quickly went nuts. This is a time consuming task: changing the values,<div><a href="http://annafilina.com/blog/camera-param-in-pv3d/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been supplied a 2D sketch of what my 3D world (PaperVision3D) will look like. The hardest part was matching the perspective by carefully positioning the camera. Having no other way than trial and error and a total of 7 different parameters, I quickly went nuts. This is a time consuming task: changing the values, recompiling, testing.</p>
<p>I wrote a tiny utility that allows you to position/rotate/zoom the camera visually, saving hours and possibly days of tweaking.</p>
<h3>How to code it</h3>
<p>Easily. Pass the camera object to the constructor and add the whole thing to your display list:</p>
<pre class="java">var cameraControl:pv3dCameraControl = new pv3dCameraControl(_camera);
addChild(cameraControl);</pre>
<h3>How to use it</h3>
<p>Click and drag the desired text field and your camera will move, updating text field&#8217;s value. Once satisfied with the result, write down the numbers!</p>
<h3>Also position objects</h3>
<p>A second, similar utility I wrote allows to position objects in the viewport.</p>
<pre class="java">var objectControl:pv3dObjectControl = new pv3dObjectControl(viewport);
addChild(objectControl);</pre>
<p>Click on an object in the viewport, then drag the desired text field.</p>
<p>Have fun.</p>
<p><a href="http://annafilina.com/blog/wp-content/uploads/2009/09/pv3dcameracontrol.as">pv3dCameraControl.as</a><a href="http://annafilina.com/blog/wp-content/uploads/2009/09/pv3dobjectcontrol.as"><br />
pv3dObjectControl.as</a></p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/camera-param-in-pv3d/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>When garbage collection does more than you want</title>
		<link>http://annafilina.com/blog/garbage-collection-does-too-much/</link>
		<comments>http://annafilina.com/blog/garbage-collection-does-too-much/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 21:04:12 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[garbage collection]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=325</guid>
		<description><![CDATA[I had an interesting Flex bug to solve a day before the project deadline. I was showing a progress bar while some images were preloading in the background. The application was only allowed to fire applicationComplete event once these images have finished loading.
The client complained that the progress bar stalls the first time you run the<div><a href="http://annafilina.com/blog/garbage-collection-does-too-much/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I had an interesting Flex bug to solve a day before the project deadline. I was showing a progress bar while some images were preloading in the background. The application was only allowed to fire applicationComplete event once these images have finished loading.</p>
<p>The client complained that the progress bar stalls the first time you run the app in the browser. Refreshing the page causes the application to start immediately, as if everything has been loaded. I reproduced the bug with bandwidth throttling. That made me think: &#8220;the assets are being fully loaded, but the progress bar doesn&#8217;t seem to care&#8221;.</p>
<p>With further investigation, I realized that I solved the same problem over a year ago. When one creates Loaders on the fly, such as in a loop, one often does not keep any reference to these Loaders outside of the scope of the function. Since it is a good habit to make event listeners weak, it is possible for the garbage collector to flag these Loaders for removal before they even have a chance to fire their complete event.</p>
<p>So to make sure that the progress bar does not stall, I needed to keep a reference to the Loader that I create within my loop. I simply pushed every Loader to an array. Once everything finished loading and the application started, I cleared the array to allow the garbage collector to take care of the rest.</p>
<h3>Problem</h3>
<p>Progress bar stalls while preloading images.</p>
<h3>Cause</h3>
<p>Loaders with weak event listeners and no references to them within the application.</p>
<h3>Solution</h3>
<p>Use an array to store references to the Loaders until all of them have finished loading.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/garbage-collection-does-too-much/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>PaperVision3D and JigLib</title>
		<link>http://annafilina.com/blog/papervision3d-and-jiglib/</link>
		<comments>http://annafilina.com/blog/papervision3d-and-jiglib/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 15:21:33 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[papervision3d]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=344</guid>
		<description><![CDATA[I experiemented with PaperVision3D and JigLib last week. Since JigLib had a plugin specifically designed for PaperVision3D, making the two work together was a breeze. The only thing that really bothered me is the fact that when I applied a force on a body, it rolled instead of gliding smoothly along the surface. I&#8217;m used to<div><a href="http://annafilina.com/blog/papervision3d-and-jiglib/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I experiemented with PaperVision3D and JigLib last week. Since JigLib had a plugin specifically designed for PaperVision3D, making the two work together was a breeze. The only thing that really bothered me is the fact that when I applied a force on a body, it rolled instead of gliding smoothly along the surface. I&#8217;m used to 2D physics engines, so that was unexpected for me.</p>
<p>I found that the documentation for JigLib was pretty limited. There is only an API without any explanation as to what the methods do and a few tutorials. Oh yes, and my physics knowledge is limited, so many terms don&#8217;t mean much to me.</p>
<p>I spent sleepless nights in the source code, trying to figure out what everything does by myself (since nobody answered my e-mails). I stumbled upon a very nice class named &#8220;JConfig&#8221;. This was the jackpot. It had a nice property &#8220;limitAngVelocities&#8221;, which was set to 10. I set it to 0 and voilà! My objects glided nicely along the surface, colliding with each other, maintaining their initial rotation.</p>
<p>I hope that this will save some sleepless nights to others.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/papervision3d-and-jiglib/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LinkBar was meant to be used with a ViewStack</title>
		<link>http://annafilina.com/blog/linkbar-with-a-viewstack/</link>
		<comments>http://annafilina.com/blog/linkbar-with-a-viewstack/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 16:53:19 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=316</guid>
		<description><![CDATA[I had to read the source code for LinkBar and its parent NavBar to understand why my LinkBar wasn&#8217;t highlighting the clicked item. Turns out, it&#8217;s because I use an ArrayCollection as a dataProvider. According to the documentation and the source code, it is possible to use an IList (such as an ArrayCollection), a String<div><a href="http://annafilina.com/blog/linkbar-with-a-viewstack/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I had to read the source code for LinkBar and its parent NavBar to understand why my LinkBar wasn&#8217;t highlighting the clicked item. Turns out, it&#8217;s because I use an ArrayCollection as a dataProvider. According to the documentation and the source code, it is possible to use an IList (such as an ArrayCollection), a String (that refers to a ViewStack in the current document) or an actual ViewStack object. But, when a selection occurs, LinkBar makes sure that we supplied a ViewStack before allowing the highlight.</p>
<p>Why, I have no idea. All I know is that I want to use an ArrayCollection as my dataProvider and still highlight clicked elements. I extended the LinkBar component with a tiny workaround. Feel free to use it as you wish.</p>
<p><a href="http://annafilina.com/blog/wp-content/uploads/2009/07/stacklesslinkbar.mxml">StacklessLinkBar</a> &#8211; forgive me if you find the name unoriginal.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/linkbar-with-a-viewstack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex: non-UIComponents in the Display List</title>
		<link>http://annafilina.com/blog/non-uicomponents-in-display-list/</link>
		<comments>http://annafilina.com/blog/non-uicomponents-in-display-list/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 22:19:13 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=279</guid>
		<description><![CDATA[There are 2 main ways to add non-UIComponents to a Flex Container.
1. You may add the object to a SWFLoader, which does not require its children to extend UIComponent.
2. You may add the object to Container.rawChildren.
You have to be careful with the 2nd one. First of all, know that whatever is contained in Container.rawChildren is not sized, positioned or<div><a href="http://annafilina.com/blog/non-uicomponents-in-display-list/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>There are 2 main ways to add non-UIComponents to a Flex Container.</p>
<p>1. You may add the object to a SWFLoader, which does not require its children to extend UIComponent.</p>
<p>2. You may add the object to Container.rawChildren.</p>
<p>You have to be careful with the 2nd one. First of all, know that whatever is contained in Container.rawChildren is not sized, positioned or rendered automatically. You cannot, for example, put a button in there. Another thing is that anything added to Container.rawChildren is NOT contained in the Container.children, but the contrary is true. Relying on indices to remove from the display list might be tricky.Here&#8217;s what I mean:</p>
<ul>
<li>You add 5 objects using Container.addChild()</li>
<li>You add 5 objects using Container.rawChildren.addChild()</li>
<li>You want to remove the last child of Container.rawChildren, and will use index 9 instead of 4, because rawChildren returns all 10 children.</li>
</ul>
<p>The reason for Container.rawChildren is to add skins, not actual content. Container.getChildren() returns only elements that were added using Container.addChild(), not elements that were added using Container.rawChildren.addChild().</p>
<p>So my suggestion to you would be to use rawChildren only if you do not intend to remove these children later, like skins. If you wish to add interactive elements and other content, create a SWFLoader and add them to it. And if you have a UIComponent, always add it to the Container using Container.addChild().</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/non-uicomponents-in-display-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Application Domain and External SWF Loading</title>
		<link>http://annafilina.com/blog/application-domain-and-external-swf-loading/</link>
		<comments>http://annafilina.com/blog/application-domain-and-external-swf-loading/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 10:35:36 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[garbage collection]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=244</guid>
		<description><![CDATA[Why do we care about application domains? I worked on a project that required me to load and unload SWF files into a bigger application (loading mini-games into a virtual world). Every time I loaded a mini-game, it would never unload when I exited it. That will keep accumulating until the app slows down to<div><a href="http://annafilina.com/blog/application-domain-and-external-swf-loading/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>Why do we care about application domains? I worked on a project that required me to load and unload SWF files into a bigger application (loading mini-games into a virtual world). Every time I loaded a mini-game, it would never unload when I exited it. That will keep accumulating until the app slows down to a crawl and crash because we&#8217;re out of memory.</p>
<p>The application domain and definition loading is one of the things that is not documented in a way the common mortal can understand. By popular demand, I will attempt to explain it the way I understand it. I will provide some examples along the way. Before I continue, here is a link to the official documentation on <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_5.html">ApplicationDomain</a>.</p>
<p>I will explain class definitions and domains, and then tell you what you can do to properly unload your movies and assets.</p>
<p><strong>Class Definitions</strong></p>
<p>Everything that you load has to be stored somewhere. It&#8217;s easy to understand the visual elements because you can just stick them on the stage. But what about class definitions?</p>
<p><span id="more-244"></span></p>
<p>For all of you who aren&#8217;t sure what class definitions are, remember all the classes that you import on top of the document when writing AS3. You can then instantiate your mx.controls.Button or flash.events.Event in the document. You can then add instances of visual components to the display list (stage).</p>
<p>Now think about your SWF for a minute. When you create a symbol in the library and export it for ActionScript, you&#8217;re basically creating a definition in the SWF. That definition will be loaded into some domain and you can instantiate it on the stage.</p>
<p>If you look at the schema, you&#8217;ll see all the class definitions in the current domain. When you close the application, all instances will be destroyed, class definitions removed and memory freed. If you decide to load an external SWF, you can choose where to load the definitions: in the same box as Class1 or in its own box.</p>
<p><strong>ApplicationDomain.currentDomain</strong></p>
<p><span style="text-decoration: underline;"><img class="aligncenter size-full wp-image-250" title="ApplicationDomain1" src="http://annafilina.com/blog/wp-content/uploads/2009/04/app-domain2.png" alt="" width="376" height="292" /><br />
</span></p>
<p>If you choose to load them in the same box as Class1, what will happen when you decide to unload your SWF? Any instances on that stage are destroyed, any definitions in its box are removed and memory is freed. Oh wait, there were no definitions in its box, so there&#8217;s nothing to remove from it. The file is unloaded in any case, but the definitions live on as a parasite in the box of our application. That&#8217;s right, a parasite. You can&#8217;t target a specific definition to unload. If you want to unload ClassC, you&#8217;ll need to unload the whole app (basically just close it). That&#8217;s not what you want to do. You want your app to run all day.</p>
<p>What is the solution? Remember there are 2 choices when loading your SWF. What if you want your loaded SWF to keep it&#8217;s garbage to itself? Sure.</p>
<p><strong>New ApplicationDomain</strong></p>
<p>So instead of loading you SWF into the application&#8217;s domain, load it into its own domain. How?</p>
<pre name="code" class="java">var appDomain:ApplicationDomain = new ApplicationDomain();
var context:LoaderContext = new LoaderContext(false, appDomain);
var loader:Loader = new Loader();
loader.load(new URLRequest("myButtons.swf"), context);</pre>
<p>We created a new domain and loaded all definitions into it. So now our application has 2 domains: the default one and a new one. You can create as many new domains as you have SWFs to load.</p>
<p><img class="aligncenter size-full wp-image-249" title="ApplicationDomain2" src="http://annafilina.com/blog/wp-content/uploads/2009/04/app-domain1.png" alt="" width="376" height="329" /></p>
<p>What will happen now if you unload your SWF? All classes are no longer in the same box, and the Loader that loaded our SWF has a reference to our new domain.  That means that when you unload your SWF, the domain (box with definitions A, B and C) will be removed and memory freed. Yay!</p>
<p><strong>Conclusion</strong></p>
<p>So what does that all mean? Should we create a new domain for EVERY file that we load? Sure you can. But you shouldn&#8217;t. There are some nice functions such as getDefinitionByName() that I want to be able to use without searching for the domain in which my definition is contained. If I have a mini-game that requires 20 SWF files, searching for that little symbol in all these domains can be painful. I would rather create 1 new domain (say domainA) and load all 20 SWFs into it. Then I can access my symbol definition from domainA, and unload this domain when no longer needed. For a second mini-game, I&#8217;ll create domainB. The idea is not to stick everything into the application&#8217;s domain.</p>
<p>Please tell me if this post helped you with your memory usage. Also, feel free to add to my explanation if I missed something.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/application-domain-and-external-swf-loading/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>AS3 Mystery: null, false, 0, &#8220;&#8221;, NaN</title>
		<link>http://annafilina.com/blog/as3-mystery-null-false-0-nan/</link>
		<comments>http://annafilina.com/blog/as3-mystery-null-false-0-nan/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 13:56:01 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[typing]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=228</guid>
		<description><![CDATA[This week I&#8217;ve been running unit tests and couldn&#8217;t understand why some of them were failing for no obvious reason. To understand why some expressions evaluated to true when they were supposed to be false. I know that I should be careful with null vs false values, but never could I have imagined that the<div><a href="http://annafilina.com/blog/as3-mystery-null-false-0-nan/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>This week I&#8217;ve been running unit tests and couldn&#8217;t understand why some of them were failing for no obvious reason. To understand why some expressions evaluated to true when they were supposed to be false. I know that I should be careful with null vs false values, but never could I have imagined that the Number 0 can be equal to an empty String!</p>
<p>I know that php&#8217;s empty() function is quite permissive, but I though AS3 was much more strict (with strict typing and all). And so I ran a different kind of test, where I checked these values in depth. Here is a table describing my results.</p>
<table border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr>
<th> </th>
<th>null</th>
<th>false</th>
<th>0</th>
<th>&#8220;&#8221;</th>
<th>NaN</th>
</tr>
<tr>
<th>isNaN() </th>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td>true</td>
</tr>
<tr>
<th>== &#8220;&#8221;</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>=== &#8220;&#8221;</th>
<td> </td>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>== null</th>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>=== null</th>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>== 0</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>=== 0</th>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>== false</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>=== false</th>
<td> </td>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>is Number</th>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
<td>true</td>
</tr>
<tr>
<th>is String</th>
<td> </td>
<td> </td>
<td> </td>
<td>true</td>
<td> </td>
</tr>
<tr>
<th>is Boolean</th>
<td> </td>
<td>true</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<th>is Object</th>
<td> </td>
<td>true</td>
<td>true</td>
<td>true</td>
<td>true</td>
</tr>
</tbody>
</table>
<p> You will notice that NaN is actually a Number and an Object, that 0 == &#8220;&#8221; == false and that false is actually an Object. There are quite a few surprises in there that will make me appreciate strict comparison.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/as3-mystery-null-false-0-nan/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Flex 3D and Wiimote</title>
		<link>http://annafilina.com/blog/flex-3d-and-wiimote/</link>
		<comments>http://annafilina.com/blog/flex-3d-and-wiimote/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 16:09:14 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[flex]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=209</guid>
		<description><![CDATA[I haven&#8217;t blogged in a while. Too much work to catch after the conference.
I&#8217;m having a lot of fun with 3D in Flex lately. I found this really great open source library papervision3d. It&#8217;s incredibly easy to use. I got the hello world to run in my existing Flex app in under 5 minutes. It&#8217;s<div><a href="http://annafilina.com/blog/flex-3d-and-wiimote/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t blogged in a while. Too much work to catch after the conference.</p>
<p>I&#8217;m having a lot of fun with 3D in Flex lately. I found this really great open source library <a href="http://blog.papervision3d.org/">papervision3d</a>. It&#8217;s incredibly easy to use. I got the hello world to run in my existing Flex app in under 5 minutes. It&#8217;s not using the native Flash 3D so it can be run in Flash Player 9.</p>
<p>After reading their blog, I also found out about the <a href="http://sourcebinder.org/">SourceBinding</a> framework (currently in alpha stage). However, the following video is a must-see for all gadget lovers.</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/fVBkQR7MCAU&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;feature=player_embedded&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/fVBkQR7MCAU&#038;color1=0xb1b1b1&#038;color2=0xcfcfcf&#038;feature=player_embedded&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/flex-3d-and-wiimote/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>lastIndexOf with RegEx?</title>
		<link>http://annafilina.com/blog/lastindexof-with-regex/</link>
		<comments>http://annafilina.com/blog/lastindexof-with-regex/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 17:38:54 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=193</guid>
		<description><![CDATA[I was quite surprised that Flex did not have a way to get the index of the LAST matching substring. I want get the index of a word&#8217;s first character based on the cursor&#8217;s position (I&#8217;m working with the text property of a UITextField).
To achieve that I&#8217;m getting all text in front of that word: text.substring(0,<div><a href="http://annafilina.com/blog/lastindexof-with-regex/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>I was quite surprised that Flex did not have a way to get the index of the LAST matching substring. I want get the index of a word&#8217;s first character based on the cursor&#8217;s position (I&#8217;m working with the text property of a UITextField).</p>
<p>To achieve that I&#8217;m getting all text in front of that word: text.substring(0, cursorPosition). Then, I simply want to search for the last non-word character (\W), if there is any. That way, I can have the index of the first character of the word.</p>
<p>So to get the last non-word character, I can&#8217;t use lastIndexOf() because it doesn&#8217;t support RegEx, I can&#8217;t use match() because it returns an array of substrings instead of indices and I can&#8217;t use search() because it returns the first index, not the last.</p>
<p>There is a way around the missing &#8220;searchLast()&#8221; and &#8220;searchAll()&#8221; functions.</p>
<p>I get a substring before the cursorPosition: text.substring(0, cursorPosition)<br />
I loop through all characters backwards and check if it&#8217;s a non-word char.<br />
Once I find it, I record the index at which it was found. </p>
<p>There might be other ways to get the beginning of a word based on cursor position, so don&#8217;t hesitate to share them. I really hope that the next SDK version will come with searchLast() and searchAll() functions.</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/lastindexof-with-regex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Randomness</title>
		<link>http://annafilina.com/blog/flex-randomness/</link>
		<comments>http://annafilina.com/blog/flex-randomness/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 22:34:07 +0000</pubDate>
		<dc:creator>Anna</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[as3]]></category>

		<guid isPermaLink="false">http://annafilina.com/blog/?p=184</guid>
		<description><![CDATA[The only reason why your Flex app should do something randomly is by your using the Math.random() function. You can argue about the UIDUtil.createUID() and such but you get the point. Today I witnessed randomness as never before.
Try to run this code (Flex 3.2)
var obj:Object = { a: "valueA", b: "valueB" };
for(var property:String in obj)
{
<div><a href="http://annafilina.com/blog/flex-randomness/">Read the rest...</a></div><br />]]></description>
			<content:encoded><![CDATA[<p>The only reason why your Flex app should do something randomly is by your using the Math.random() function. You can argue about the UIDUtil.createUID() and such but you get the point. Today I witnessed randomness as never before.</p>
<p>Try to run this code (Flex 3.2)</p>
<pre name="code" class="java">var obj:Object = { a: "valueA", b: "valueB" };
for(var property:String in obj)
{
    trace(property);
}</pre>
<p>Sometimes it will output a-b and other times b-a. I have no idea how it determines the order and how come it&#8217;s never the same. But it sure caused me some pain. Found a workaround using PHP once received on the back-end!</p>
]]></content:encoded>
			<wfw:commentRss>http://annafilina.com/blog/flex-randomness/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
