<?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 &#187; as</title>
	<atom:link href="http://flassari.is/tag/as/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>AS3 &#8220;with&#8221; keyword and casting</title>
		<link>http://flassari.is/2010/07/as3-with-keyword-and-casting/</link>
		<comments>http://flassari.is/2010/07/as3-with-keyword-and-casting/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 13:40:40 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[as]]></category>
		<category><![CDATA[cast]]></category>
		<category><![CDATA[casting]]></category>
		<category><![CDATA[keyword]]></category>
		<category><![CDATA[with]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=321</guid>
		<description><![CDATA[I&#8217;ve rarely (if ever) used the &#8220;with&#8221; keyword in as3, but I recently found a neat trick to use it with. When I quickly need to cast an object to access a few methods/properties I don&#8217;t always want to create a new casted variable: var child:DisplayObject = getChildThatMightBeMovieClip(); if (child is MovieClip) { var childAsMc:MovieClip [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve rarely (if ever) used the <a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/statements.html#with">&#8220;with&#8221; keyword</a> in as3, but I recently found a neat trick to use it with.</p>
<p>When I quickly need to cast an object to access a few methods/properties I don&#8217;t always want to<br />
create a new casted variable:</p>
<pre class="brush: as3">var child:DisplayObject = getChildThatMightBeMovieClip();

if (child is MovieClip) {
	var childAsMc:MovieClip = child as MovieClip;
	trace(childAsMc.numChildren);
	trace(childAsMc.currentFrame);
}</pre>
<p>or cast it every single time:</p>
<pre class="brush: as3">var child:DisplayObject = getChildThatMightBeMovieClip();

if (child is MovieClip) {
	trace((child as MovieClip).numChildren);
	trace((child as MovieClip).currentFrame);
}</pre>
<p>Using the &#8220;with&#8221; keyword, we can temporarily cast it without creating a temporary casted variable or casting it again and again:</p>
<pre class="brush: as3">var child:DisplayObject = getChildThatMightBeMovieClip();

if (child is MovieClip) {
	with (child as MovieClip) {
		trace(numChildren);
		trace(currentFrame);
	}
}</pre>
<p>Elegant =)</p>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2010/07/as3-with-keyword-and-casting/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Global error handling with Flash Player 10.1</title>
		<link>http://flassari.is/2010/06/global-error-handling-with-flash-player-10-1/</link>
		<comments>http://flassari.is/2010/06/global-error-handling-with-flash-player-10-1/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 12:25:44 +0000</pubDate>
		<dc:creator>Flassari</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[10.1]]></category>
		<category><![CDATA[4.1]]></category>
		<category><![CDATA[as]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[handler]]></category>
		<category><![CDATA[handling]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[SDK]]></category>
		<category><![CDATA[uncaught]]></category>
		<category><![CDATA[uncaughtError]]></category>
		<category><![CDATA[uncaughterrorhandler]]></category>

		<guid isPermaLink="false">http://flassari.is/?p=303</guid>
		<description><![CDATA[Since the official release of Flash Player 10.1 is out, now might be a good time to start implementing the global error handler.

When this is written, flash builder 4 doesn't have a native way that lets you use it, so we have to do a little mix.
The global error handler works by adding an event to the uncaughtErrorEvents property of the loaderInfo of the application.
There are currently two methods of getting it to work [...] ]]></description>
			<content:encoded><![CDATA[<p>Since the official release of Flash Player 10.1 is out, now might be a good time to start implementing the global error handler.</p>
<p>When this is written, flash builder 4 doesn&#8217;t have a native way that lets you use it, so we have to do a little mix.<strong> (Update: The update is out.)</strong><br />
The global error handler works by adding an event to the uncaughtErrorEvents property of the loaderInfo of the application.<br />
There are currently two methods of getting it to work.</p>
<h3>Method 1 - The backwards compatible one:</h3>
<p>Here the code doesn&#8217;t crash in flash player 9/10, but the error handling will only work in 10.1.</p>
<pre class="brush: as3">if(loaderInfo.hasOwnProperty("uncaughtErrorEvents")){
	IEventDispatcher(loaderInfo["uncaughtErrorEvents"]) .addEventListener("uncaughtError", uncaughtErrorHandler);
}</pre>
<pre class="brush: as3">private function uncaughtErrorHandler(e:Event):void {
	trace("Global error:", e);
}</pre>
<h3>Method 2 - The type safe one:</h3>
<p>Get the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4">Flex 4.1 SDK</a> if you haven&#8217;t already and choose that one as your project&#8217;s SDK.</p>
<p>Now you can use the new global error handling like it was meant to be used:</p>
<pre class="brush: as3">import flash.events.UncaughtErrorEvent;

loaderInfo.uncaughtErrorEvents.addEventListener( UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);

private function uncaughtErrorHandler( e:UncaughtErrorEvent):void {
	trace("Global error:", e);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://flassari.is/2010/06/global-error-handling-with-flash-player-10-1/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

