<?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>Flassari.is</title>
	<atom:link href="http://flassari.is/feed/" rel="self" type="application/rss+xml" />
	<link>http://flassari.is</link>
	<description></description>
	<lastBuildDate>Fri, 13 Apr 2012 11:51:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<item>
		<title>Throwing an error in a constructor before the super() statement</title>
		<link>http://flassari.is/2012/04/throwing-an-error-in-a-constructor-before-the-super-statement/</link>
		<comments>http://flassari.is/2012/04/throwing-an-error-in-a-constructor-before-the-super-statement/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 11:51:54 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[1201]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[flex compiler]]></category>
		<category><![CDATA[super]]></category>
		<category><![CDATA[throw]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=492</guid>
		<description><![CDATA[I would have thought you could throw an error whenever you pleased like it, however the Flex compiler has some other ideas. If you have a throw statement before the super() in the constructor, Flex will complain with the following error code: 1201: A super statement cannot occur after a this, super, return, or throw [...]]]></description>
			<content:encoded><![CDATA[<p>I would have thought you could throw an error whenever you pleased like it, however the Flex compiler has some other ideas.</p>
<p>If you have a throw statement before the super() in the constructor, Flex will complain with the following error code:<br />
<b><i>1201: A super statement cannot occur after a this, super, return, or throw statement.</i></b></p>
<p>There is a workaround though, just wrap the throw statement in an anonymous function:</p>
<pre class="brush: as3">(function():void {
	throw new Error("Yay for workarounds!");
})();</pre>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2012/04/throwing-an-error-in-a-constructor-before-the-super-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>External Interface error: Object expected</title>
		<link>http://flassari.is/2012/02/external-interface-error-object-expected/</link>
		<comments>http://flassari.is/2012/02/external-interface-error-object-expected/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 14:38:43 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[Stage3D]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[external interface]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[FB.ui]]></category>
		<category><![CDATA[hideFlashCallback]]></category>
		<category><![CDATA[Object expected]]></category>
		<category><![CDATA[swf]]></category>
		<category><![CDATA[visibility]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=480</guid>
		<description><![CDATA[It&#8217;s taken me a while to figure this one out. I have a flash game on facebook that uses Stage3D, so window mode has to be set to &#8220;direct&#8221; which means that any time facebook wants to overlay some elements on the page they appear under the game on many browsers. Facebook has a solution [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s taken me a while to figure this one out. I have a <a href="http://facebook.angrybirds.com" target="_blank">flash game on facebook</a> that uses Stage3D, so window mode has to be set to &#8220;direct&#8221; which means that any time facebook wants to overlay some elements on the page they appear under the game on many browsers.</p>
<p>Facebook has a solution for you, on FB.init you can set your own callback function via the hideFlashCallback parameter. In this callback you <a href="http://developers.facebook.com/blog/post/637/" target="_blank">can move the flash object out of view</a> by, for example, setting the top to be -10000px whenever a Facebook dialog is opened and then putting it back when the dialog is closed.</p>
<p>I had functions registered with external interface to pause and resume the game that would get called via javascript in the hideFlashCallback callback.</p>
<p>This was working well enough but for some reason on Internet Explorer I couldn&#8217;t call the resume() function just after showing the flash object, instead I got an &#8220;Object Expected&#8221; error.</p>
<p>Internet Explorer does not support calling external interface methods for flash objects if they are not visible. Since it could be a race condition (DOM might not render the flash object before the function was called) I added a 100ms delay to the call to resume(), only for IE. This seemed to work fine.</p>
<p>But once we got close to production this error re-appeared, but only when Facebook&#8217;s purchase dialog had been shown. Weird! No amount of delay made the external interface calls work again. If I showed the purchase dialog once and closed it, it would be no longer possible to call any external interface functions for the flash object until a page refresh. This was not acceptable.</p>
<p>After a lot of debugging, I noticed that even though we have registered for the hideFlashCallback function, facebook STILL sets the visibility of the flash object to &#8220;hidden&#8221; after 200ms.</p>
<p>As can be seen in <a href="https://developers.facebook.com/docs/reference/javascript/#hide_flash_callback" target="_blank">Facebook&#8217;s documentation</a>: &#8220;The custom action must complete within 200ms or the Flash object will be hidden automatically regardless.&#8221;</p>
<p>Apparently the fact that we&#8217;re changing the visibility of the flash object along with whatever facebook does differently during the purchase dialog (overlay a white div over the whole page) breaks all external interface functionality.</p>
<p>This has a simple fix though, create a higher priority CSS rule that makes the flash object always visible:</p>
<pre class="brush: xml">
<style>
#MyFlashObjectID {
    visibility: visible !important;
}
</style>
</pre>
<p>It doesn&#8217;t need to be hidden since we are moving it out of view ourselves anyways.</p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2012/02/external-interface-error-object-expected/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Showing static variables in the Flash Builder 4.5 debugger</title>
		<link>http://flassari.is/2012/01/showing-static-variables-in-the-flash-builder-4-5-debugger/</link>
		<comments>http://flassari.is/2012/01/showing-static-variables-in-the-flash-builder-4-5-debugger/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 08:15:16 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[builder]]></category>
		<category><![CDATA[debugger]]></category>
		<category><![CDATA[show]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=472</guid>
		<description><![CDATA[For some reason this option is turned off by default. To see the static variables of your classes, simply click the small down-facing triangle on the top-right of the variables panel, and click Flex->Show Static Variables.]]></description>
			<content:encoded><![CDATA[<p>For some reason this option is turned off by default.<br />
To see the static variables of your classes, simply click the small down-facing triangle on the top-right of the variables panel, and click Flex->Show Static Variables.</p>
<p><img src="http://flassari.is/wp-content/uploads/2012/01/Static.png" alt="Show static variables in Flash Builder" title="Show static variables in Flash Builder" width="433" height="175" class="alignnone size-full wp-image-473" /></p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2012/01/showing-static-variables-in-the-flash-builder-4-5-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Angry Birds coming to Facebook</title>
		<link>http://flassari.is/2012/01/angry-birds-coming-to-facebook/</link>
		<comments>http://flassari.is/2012/01/angry-birds-coming-to-facebook/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 17:53:44 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[angry birds]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[rovio]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=463</guid>
		<description><![CDATA[Finally, I&#8217;ve been working as a Senior Developer on the Angry Birds facebook game for a few months now, and its been announced! Rovio has created an official facebook event at http://www.facebook.com/events/174654275973227/. After the workload decreases I should be able to start writing again, I have some PureMVC stuff I&#8217;m dying to write about.]]></description>
			<content:encoded><![CDATA[<p>Finally, I&#8217;ve been working as a Senior Developer on the Angry Birds facebook game for a few months now, and its been announced!<br />
Rovio has created an official facebook event at <a href="http://www.facebook.com/events/174654275973227/">http://www.facebook.com/events/174654275973227/</a>.</p>
<p><img src="http://flassari.is/wp-content/uploads/2012/01/AngryBirdsFacebook.jpg" alt="Angry Birds on Facebook" title="Angry Birds on Facebook" width="180" height="180" class="alignnone size-full wp-image-466" /></p>
<p>After the workload decreases I should be able to start writing again, I have some PureMVC stuff I&#8217;m dying to write about.</p>
<p><iframe width="450" height="259" src="http://www.youtube.com/embed/qS0NQ3CtKhg" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2012/01/angry-birds-coming-to-facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Error #3692: All buffers need to be cleared every frame before drawing</title>
		<link>http://flassari.is/2011/11/error-3692-all-buffers-need-to-be-cleared-every-frame-before-drawing/</link>
		<comments>http://flassari.is/2011/11/error-3692-all-buffers-need-to-be-cleared-every-frame-before-drawing/#comments</comments>
		<pubDate>Fri, 18 Nov 2011 09:12:26 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[3692]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[bitmapdata]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[buffers]]></category>
		<category><![CDATA[context3d]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[Starling]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=457</guid>
		<description><![CDATA[So I have this Starling project and wanted to take a screenshot of the Stage3D currently in use. I was trying to use the Context3D.drawToBitmapData() function and kept getting this error: &#8220;Error #3692: All buffers need to be cleared every frame before drawing.&#8221; Googling around yielded no results, so after figuring out the problem I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>So I have this Starling project and wanted to take a screenshot of the Stage3D currently in use.<br />
I was trying to use the Context3D.drawToBitmapData() function and kept getting this error:<br />
&#8220;Error #3692: All buffers need to be cleared every frame before drawing.&#8221;</p>
<p>Googling around yielded no results, so after figuring out the problem I&#8217;m posting the solution here for anyone else having this problem.</p>
<p>The solution is short: you have to call drawToBitmapData() BEFORE the Context3D.present() call.</p>
<p>In my case with Starling I had to add the functionality in the Starling.render() function, between the call to mStage.render() and the call to mContext.present().</p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2011/11/error-3692-all-buffers-need-to-be-cleared-every-frame-before-drawing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mxmlc ANT compiler error: &#8220;Error: Java heap space&#8221;</title>
		<link>http://flassari.is/2011/09/mxmlc-ant-compiler-error-error-java-heap-space/</link>
		<comments>http://flassari.is/2011/09/mxmlc-ant-compiler-error-error-java-heap-space/#comments</comments>
		<pubDate>Thu, 29 Sep 2011 12:34:08 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[ANT]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[ANT_OPTS]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[compiler]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fork]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java heap space]]></category>
		<category><![CDATA[jvm]]></category>
		<category><![CDATA[maxmemory]]></category>
		<category><![CDATA[mxmlc]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=441</guid>
		<description><![CDATA[A simple error that causes a lot of headache that has a simple solution that is hard to find on the internet. Don&#8217;t you just love these problems? If you are calling mxmlc via ANT you&#8217;ve probably seen this error and had to resort to solutions like setting the ANT_OPTS or Java arguments for the [...]]]></description>
			<content:encoded><![CDATA[<p>A simple error that causes a lot of headache that has a simple solution that is hard to find on the internet.<br />
Don&#8217;t you just love these problems?</p>
<p>If you are calling mxmlc via ANT you&#8217;ve probably seen this error and had to resort to solutions like setting the ANT_OPTS or Java arguments for the SDK on every single computer that uses that build script.</p>
<p>The solution is actually much simpler than that, mxmlc allows you to set this in the ANT target itself. Just add the parameters fork=&#8221;true&#8221; to make it run on it&#8217;s own Java thread, and then set maxmemory to something like &#8220;1024m&#8221;.</p>
<pre class="brush: as3"><mxmlc
	file="Main.as"
	output="Output.swf"
	fork="true"
	maxmemory="1024m"
>
	<!-- Other configurations -->
</mxmlc></pre>
<p>It would have been nice if adobe had this in the <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=anttasks_1.html">documentation</a>, but no such luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2011/09/mxmlc-ant-compiler-error-error-java-heap-space/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AS3 Polygon Clipper</title>
		<link>http://flassari.is/2011/05/as3-polygon-clipper/</link>
		<comments>http://flassari.is/2011/05/as3-polygon-clipper/#comments</comments>
		<pubDate>Mon, 23 May 2011 09:00:35 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Math]]></category>
		<category><![CDATA[alchemy]]></category>
		<category><![CDATA[boolean]]></category>
		<category><![CDATA[clip]]></category>
		<category><![CDATA[clipper]]></category>
		<category><![CDATA[clipping]]></category>
		<category><![CDATA[commercial]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[free]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[GPC]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[mask]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[polygon]]></category>
		<category><![CDATA[polygon boolean operation]]></category>
		<category><![CDATA[remove]]></category>
		<category><![CDATA[subtract]]></category>
		<category><![CDATA[swc]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=408</guid>
		<description><![CDATA[I was looking for an open source polygon clipper library for AS3 to use on a commercial project. I found a few ports of the General Polygon Clipper library (GPC) but it is only free for non-commercial projects. After more searching around I found this excellent library called Clipper by Angus Johnson. It did not [...]]]></description>
			<content:encoded><![CDATA[<p><center><img src="http://flassari.is/wp-content/uploads/2011/05/A-B.png" title="Polygon Clipper" /></center><br />
I was looking for an open source polygon clipper library for AS3 to use on a commercial project.<br />
I found a <a href="http://code.google.com/p/gpcas/">few</a> <a href="http://code.google.com/p/polygonal/wiki/GeneralPolygonClipperAlgorithm">ports</a> of the General Polygon Clipper library (<a href="http://www.cs.man.ac.uk/~toby/alan/software/">GPC</a>) but it is <a href="http://www.cs.man.ac.uk/~toby/alan/software/#Licensing">only free for non-commercial projects</a>.<br />
After more searching around I found this excellent library called <a href="http://www.angusj.com/delphi/clipper.php">Clipper by Angus Johnson</a>. It did not have an AS3 port so I made one using <a href="http://labs.adobe.com/technologies/alchemy/">Alchemy</a> to wrap the c++ code.</p>
<p>The SWC and source code can be found on github: <a href="https://github.com/Flassari/as3clipper">https://github.com/Flassari/as3clipper</a></p>
<p>It is completely free and open source for both personal and commercial projects. Clipper uses the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License</a>.</p>
<p>Supported clipping operations: difference, intersection, union and XOR.</p>
<p>Here&#8217;s an example of how to use the AS3 port after importing the Clipper.swc file:</p>
<pre class="brush:as3">import com.flassari.geom.Clipper;
import com.flassari.geom.ClipType;

var subjectPolygon:Array = [new Point(0, 0), new Point(200, 0), new Point(100, 200)];

var clipPolygon:Array = [new Point(0, 100), new Point(200, 100), new Point(300, 200)];

var resultPolygons:Array = Clipper.clipPolygon(subjectPolygon, clipPolygon, ClipType.DIFFERENCE);</pre>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2011/05/as3-polygon-clipper/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Prefixing private variables with an underscore in AS3</title>
		<link>http://flassari.is/2011/04/prefixing-private-variables-with-an-underscore-in-as3/</link>
		<comments>http://flassari.is/2011/04/prefixing-private-variables-with-an-underscore-in-as3/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 19:00:03 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding conventions]]></category>
		<category><![CDATA[convention]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[getter]]></category>
		<category><![CDATA[prefix]]></category>
		<category><![CDATA[private]]></category>
		<category><![CDATA[public]]></category>
		<category><![CDATA[rule]]></category>
		<category><![CDATA[rules]]></category>
		<category><![CDATA[setter]]></category>
		<category><![CDATA[standard]]></category>
		<category><![CDATA[underscore]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=383</guid>
		<description><![CDATA[A coworker and I had a discussion about using underscores for private variables in AS3. I&#8217;ve always added an underscore before my private variables, like so: private var _myVariable:int; While he wanted to only use underscores for when you have a variable which has a getter/setter: private var _myGetAndOrSetVariable:int; private var myPrivateVariable:int; public function get [...]]]></description>
			<content:encoded><![CDATA[<p>A coworker and I had a discussion about using underscores for private variables in AS3.<br />
I&#8217;ve always added an underscore before my private variables, like so:</p>
<pre class="brush:as3">private var _myVariable:int;</pre>
<p>While he wanted to only use underscores for when you have a variable which has a getter/setter:</p>
<pre class="brush:as3">private var _myGetAndOrSetVariable:int;
private var myPrivateVariable:int;

public function get myGetAndOrSetVariable():int {
	return _myGetAndOrSetVariable;
}</pre>
<p>This was a little alien to me and I didn&#8217;t get the point of it. Why should you only sometimes use an underscore? He answered that then you know that private variable has a getter/setter if it has an underscore.</p>
<p>Well, that&#8217;s not a bad reason. I googled around and it sounds like Adobe actually enforces this kind of rule in their <a href="http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions#CodingConventions-Storagevariablenames" target="_blank">Coding Conventions document</a>; &#8220;Give the storage variable for the getter/setter foo the name _foo.&#8221;.<br />
They don&#8217;t say anything about if the other variables shouldn&#8217;t have underscores though, so I dived into the source code of the Flex SDK to see what they were using.<br />
Turns out, both! In some classes every single private variable had an underscore, and in other ones only variables with a public getter/setter had one.<br />
In <a href="http://active.tutsplus.com/articles/open-mike/open-mike-prefixes/">this poll</a>, majority of AS3 developers always use underscores.</p>
<p>I thought long and hard, and I came up with these reasons for why one should always use underscores for private variables:</p>
<ul style="list-style-type:disc">
<li>It can be confusing &#8220;sometimes and sometimes not&#8221; putting an underscore.</li>
<li>You can see immediately if the variable is accessible to another class when you always prefix private variables with underscores.</li>
<li>Most of the in-house code and frameworks always use underscores (consistency).</li>
<li>Pressing ctrl+space for IDE code completion shows you all the local private variables if you type an underscore first, if you don&#8217;t you get every single variable in the class with every class in the project together in one gigantic list.</li>
<li><a href="http://active.tutsplus.com/articles/open-mike/open-mike-prefixes/">Most other coders</a> and their frameworks online use it.</li>
<li>If you are going to create a getter/setter for the variable, you have to rename it first to include the underscore.</li>
<ul style="list-style-type:circle">
<li>Also, if you rename it without refactoring, all references in the class will now pull from the getter (possible calling extra code) when maybe they were only supposed to get the raw data.</li>
</ul>
<li>If the other method is used I will know much less about the variable just from looking at it, possible making debugging harder. It could be a local variable, a class function, a function parameter, a private variable without a getter/setter, a getter/setter function or a public variable.</li>
</ul>
<p>Personally, I don&#8217;t really care when I&#8217;m writing code in a class if a variable has a getter/setter. That&#8217;s encapsulation, and I think mostly of it when working in/thinking of other classes that interact with the current one. I much more care knowing if I&#8217;m working with a variable or calling a getter function (it could be a public variable too, but still less complicated).<br />
I also prefer to write &#8220;_id = id&#8221; instead of &#8220;this.id = id&#8221;.</p>
<p>Also, adding an underscore just to avoid a name conflict doesn&#8217;t sound proper to me. It sounds like you had to make a workaround to make the code do what you want (read: a shit mix).</p>
<p>So far these are enough reasons for me to stick with prefixing my private variables with underscores. I have an open mind though, a comment can easily change my mind if it has the right arguments.</p>
<p>What is your method, and why? Please do share =)</p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2011/04/prefixing-private-variables-with-an-underscore-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Populating a Vector in the constructor</title>
		<link>http://flassari.is/2011/01/populating-a-vector-in-the-constructor/</link>
		<comments>http://flassari.is/2011/01/populating-a-vector-in-the-constructor/#comments</comments>
		<pubDate>Wed, 19 Jan 2011 15:12:34 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[constructor]]></category>
		<category><![CDATA[populate vector]]></category>
		<category><![CDATA[Vector]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=380</guid>
		<description><![CDATA[There is a small difference between populating a Vector while instancing it and an Array. While an Array is instanced this way: var names:Array = ["Bob", "Larry", "Sarah"]; a Vector can be instanced like this: // In the constructor var names:Vector.&#60;String> = new &#60;String>["Bob", "Larry", "Sarah"]; // Converting from a regular Array using the Vector [...]]]></description>
			<content:encoded><![CDATA[<p>There is a small difference between populating a Vector while instancing it and an Array.<br />
While an Array is instanced this way:</p>
<pre class="brush: as3">var names:Array = ["Bob", "Larry", "Sarah"];</pre>
<p>a Vector can be instanced like this:</p>
<pre class="brush: as3">// In the constructor
var names:Vector.&lt;String> = new &lt;String>["Bob", "Larry", "Sarah"];
// Converting from a regular Array using the Vector global (about three times slower)
var names:Vector.&lt;String> = Vector.&lt;String>(["Bob", "Larry", "Sarah"]);</pre>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2011/01/populating-a-vector-in-the-constructor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preloader without a loader-swf in AS3</title>
		<link>http://flassari.is/2010/11/preloader-without-a-loader-swf-in-as3/</link>
		<comments>http://flassari.is/2010/11/preloader-without-a-loader-swf-in-as3/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 16:08:26 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[factory]]></category>
		<category><![CDATA[factoryclass]]></category>
		<category><![CDATA[flex sdk]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[loader-swf]]></category>
		<category><![CDATA[preloader]]></category>
		<category><![CDATA[single swf]]></category>
		<category><![CDATA[swf]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=359</guid>
		<description><![CDATA[Here&#8217;s one method of loading your AS3 movie, using a preloader class that loads before all other classes. The flex compiler can actually split up the code for you so one class loads before all others. Even though we&#8217;re using the flex compiler to do this we do not have to have a Flex project, [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s one method of loading your AS3 movie, using a preloader class that loads before all other classes.</p>
<p>The flex compiler can actually split up the code for you so one class loads before all others. Even though we&#8217;re using the flex compiler to do this we do not have to have a Flex project, it can be a Flash project or a pure actionscript project. If we&#8217;re using a Flash project we do have to set the flex compiler path though.</p>
<p>Anyways, the way it works is that in your main class you add the Frame metadata, like this:</p>
<pre class="brush:as3">package com.flassari {
// Preloader meta tag
[Frame(factoryClass="com.flassari.Preloader")]
// Start of our own application code
[SWF(backgroundColor="#FFFFFF", frameRate="24", width="800", height="600", pageTitle="My preloaded project")]
public class Main extends Sprite
{</pre>
<p>The preloader has to extend movieClip, because behind the scenes it is using frames for its magic.<br />
In your preloader class, when it is done loading (by checking if it is at the last frame), your have to instantiate the main class with no strict typing. If you were to use strict typing, the whole application would have to load before the preloader can be shown so that would defeat the purpose of a preloader:</p>
<pre class="brush:as3">private function onEnterFrame(e:Event):void {
	if (currentFrame == totalFrames) { // If we're at the frame where Main is ready
		// Stop and clean up
		stop();
		removeEventListener(Event.ENTER_FRAME, onEnterFrame);
		// Create the main application and add it to the display list
		var mainClass:Class = getDefinitionByName("com.flassari.Main") as Class;
		addChild(new mainClass() as DisplayObject);
	}
}</pre>
<p>Just remember, everything that the preloader references will be loaded before the preloader can be shown, so keep it to a minimum.<br />
Also, because the main class is created before it is put on the stage, be sure not to reference the stage in the constructor.</p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2010/11/preloader-without-a-loader-swf-in-as3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

