<?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>Life As An Evangelist &#187; Tom Krcha</title>
	<atom:link href="http://lifeasanevangelist.com/author/tom-krcha/feed/" rel="self" type="application/rss+xml" />
	<link>http://lifeasanevangelist.com</link>
	<description>Keep up to date with Adobe's Platform Evangelists</description>
	<lastBuildDate>Wed, 08 Feb 2012 05:13:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>tomkrcha: Blogged: Casting basic types from AS3 to C with AIR native extensions http://t.co/akr6uPtA</title>
		<link>http://twitter.com/tomkrcha/statuses/166922049669971968</link>
		<comments>http://twitter.com/tomkrcha/statuses/166922049669971968#comments</comments>
		<pubDate>Tue, 07 Feb 2012 16:31:32 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166922049669971968</guid>
		<description><![CDATA[tomkrcha: Blogged: Casting basic types from AS3 to C with AIR native extensions http://t.co/akr6uPtA]]></description>
			<content:encoded><![CDATA[tomkrcha: Blogged: Casting basic types from AS3 to C with AIR native extensions http://t.co/akr6uPtA]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/07/tomkrcha-blogged-casting-basic-types-from-as3-to-c-with-air-native-extensions-httpt-coakr6upta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: HOWTO: Transfer Number, String, int/uint and Boolean with AIR Native Extensions for iOS back and forth http://t.co/akr6uPtA</title>
		<link>http://twitter.com/tomkrcha/statuses/166921644143681536</link>
		<comments>http://twitter.com/tomkrcha/statuses/166921644143681536#comments</comments>
		<pubDate>Tue, 07 Feb 2012 16:29:55 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166921644143681536</guid>
		<description><![CDATA[tomkrcha: HOWTO: Transfer Number, String, int/uint and Boolean with AIR Native Extensions for iOS back and forth http://t.co/akr6uPtA]]></description>
			<content:encoded><![CDATA[tomkrcha: HOWTO: Transfer Number, String, int/uint and Boolean with AIR Native Extensions for iOS back and forth http://t.co/akr6uPtA]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/07/tomkrcha-howto-transfer-number-string-intuint-and-boolean-with-air-native-extensions-for-ios-back-and-forth-httpt-coakr6upta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HOWTO: Transfer Number, String, int/uint and Boolean with AIR Native Extensions for iOS back and forth</title>
		<link>http://www.flashrealtime.com/transfer-string-number-int-uint-bool-ane/</link>
		<comments>http://www.flashrealtime.com/transfer-string-number-int-uint-bool-ane/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 16:24:54 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[blogs]]></category>

		<guid isPermaLink="false">http://www.flashrealtime.com/?p=2567</guid>
		<description><![CDATA[Casting basic types from ActionScript 3 to C Your probably first and immediate question when programming ANE for iOS is: &#8220;How to transfer data from AS3 to C and back to AS3?&#8221;. Once you break through this essential stage you enter the world of endless possibilities in Adobe AIR with native extensions. There has been [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http://www.flashrealtime.com/transfer-string-number-int-uint-bool-ane/"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http://www.flashrealtime.com/transfer-string-number-int-uint-bool-ane/&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<h3>Casting basic types from ActionScript 3 to C</h3>
<p>Your probably first and immediate question when programming ANE for iOS is: &#8220;How to transfer data from AS3 to C and back to AS3?&#8221;. Once you break through this essential stage you enter the world of endless possibilities in Adobe AIR with native extensions.</p>
<p>There has been already <a href="http://www.adobe.com/devnet/air/native-extensions-for-air.html">plenty of articles</a> on how to begin writing your native extensions, I am not going to explain that, just share the source code needed for that.<br />
I am using Adobe Flash Builder 4.6 with ANE support for AS3 and Apple Xcode for coding the C part + packaging the static library (*.a file).<br />
But let me quickly remind you the workflow. You need 3 projects, one is Flex Library project in FB (AS3 interface for C as *.swc), second is native library in Xcode (C interface and implementation as static library *.a), third is the actual test project in FB to run the native extension (*.ane).</p>
<p>Fig: Native Extension Creation Process<br />
<img src="http://www.flashrealtime.com/wp-content/uploads/2012/02/NativeExtensionProcess.png" alt="" title="NativeExtensionProcess" width="480" height="425" class="alignnone size-full wp-image-2592" /></p>
<p>In this tutorial I want to illustrate how to transfer some basic types like Number, String, int/uint and Boolean from AS3 to C, process them and return back to AS3. In the next tutorial, we will look into more complex data types like Array, ByteArray and BitmapData.</p>
<p>Good starting point: <a href="http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-8000.html">Native C API Reference</a> for Adobe AIR extensions. There is also a good page <a href="http://help.adobe.com/en_US/air/extensions/WS460ee381960520ad-866f9c112aa6e1ad46-8000.html">Coding native side with C</a> for AIR.</p>
<p>But there is nothing better than samples. Let&#8217;s dig into some real code:</p>
<h3>Number (AS3->C->AS3) Sum function</h3>
<p>AS3 part:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> sum<span style="color: #66cc66;">&#40;</span>number1:<span style="color: #0066CC;">Number</span>,number2:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#123;</span>
       <span style="color: #808080; font-style: italic;">// call C function sum with 2 arguments, number 1 and number2 and return a value</span>
	<span style="color: #000000; font-weight: bold;">var</span> ret:<span style="color: #0066CC;">Number</span> = context.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;sum&quot;</span>,number1,number2<span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Number</span>;
	<span style="color: #b1b100;">return</span> ret;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>C part:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREObject sum<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> funcData<span style="color: #339933;">,</span> uint32_t argc<span style="color: #339933;">,</span> FREObject argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// argc ... argument count, uint</span>
    <span style="color: #666666; font-style: italic;">// argv ... argument values, Array</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// retrieve first argument and write it to a variable</span>
    <span style="color: #993333;">double</span> number1<span style="color: #339933;">;</span>
    FREGetObjectAsDouble<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>number1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// retrieve second argument and write it to a variable</span>
    <span style="color: #993333;">double</span> number2<span style="color: #339933;">;</span>
    FREGetObjectAsDouble<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>number2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// add first and second number together</span>
    <span style="color: #993333;">double</span> sum <span style="color: #339933;">=</span> number1 <span style="color: #339933;">+</span> number2<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// write computed sum to FREObject that will be returned back to AS3</span>
    FREObject sumToReturn <span style="color: #339933;">=</span> nil<span style="color: #339933;">;</span>
    FRENewObjectFromDouble<span style="color: #009900;">&#40;</span>sum<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>sumToReturn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> sumToReturn<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>int (AS3->C->AS3) Subtract function</h3>
<p>AS3 part:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> subtract<span style="color: #66cc66;">&#40;</span>int1:<span style="color: #0066CC;">int</span>,int2:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">int</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> ret:<span style="color: #0066CC;">Number</span> = context.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;subtract&quot;</span>,int1,int2<span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">int</span>;
	<span style="color: #b1b100;">return</span> ret;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>C part:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREObject subtract<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> funcData<span style="color: #339933;">,</span> uint32_t argc<span style="color: #339933;">,</span> FREObject argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    int32_t int1<span style="color: #339933;">;</span>
    FREGetObjectAsInt32<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>int1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    int32_t int2<span style="color: #339933;">;</span>
    FREGetObjectAsInt32<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>int2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    int32_t sum <span style="color: #339933;">=</span> int1 <span style="color: #339933;">-</span> int2<span style="color: #339933;">;</span>
&nbsp;
    NSLog<span style="color: #009900;">&#40;</span>@<span style="color: #ff0000;">&quot;%d-%d=%d&quot;</span><span style="color: #339933;">,</span>int1<span style="color: #339933;">,</span>int2<span style="color: #339933;">,</span>sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    FREObject sumToReturn <span style="color: #339933;">=</span> nil<span style="color: #339933;">;</span>
    FRENewObjectFromInt32<span style="color: #009900;">&#40;</span>sum<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>sumToReturn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> sumToReturn<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>uint (AS3->C->AS3) Multiply function</h3>
<p>AS3 part:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> multiply<span style="color: #66cc66;">&#40;</span>uint1:uint,uint2:uint<span style="color: #66cc66;">&#41;</span>:uint<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> ret:<span style="color: #0066CC;">Number</span> = context.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;multiply&quot;</span>,uint1,uint2<span style="color: #66cc66;">&#41;</span> as uint;
	<span style="color: #b1b100;">return</span> ret;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>C part:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREObject multiply<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> funcData<span style="color: #339933;">,</span> uint32_t argc<span style="color: #339933;">,</span> FREObject argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    uint32_t uint1<span style="color: #339933;">;</span>
    FREGetObjectAsUint32<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>uint1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    uint32_t uint2<span style="color: #339933;">;</span>
    FREGetObjectAsUint32<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>uint2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    uint32_t sum <span style="color: #339933;">=</span> uint1<span style="color: #339933;">*</span>uint2<span style="color: #339933;">;</span>
&nbsp;
    NSLog<span style="color: #009900;">&#40;</span>@<span style="color: #ff0000;">&quot;%d*%d=%d&quot;</span><span style="color: #339933;">,</span>uint1<span style="color: #339933;">,</span>uint2<span style="color: #339933;">,</span>sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    FREObject sumToReturn <span style="color: #339933;">=</span> nil<span style="color: #339933;">;</span>
    FRENewObjectFromUint32<span style="color: #009900;">&#40;</span>sum<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>sumToReturn<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> sumToReturn<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>String (AS3->C->AS3) Concatenate function</h3>
<p>AS3 part:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> concatenate<span style="color: #66cc66;">&#40;</span>str1:<span style="color: #0066CC;">String</span>,str2:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> ret:<span style="color: #0066CC;">String</span> = context.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;concatenate&quot;</span>,str1,str2<span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">String</span>;
	<span style="color: #b1b100;">return</span> ret;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>C/Obj-C part:<br />
// in this sample I wanted to go even further and utilize Obj-C function for concatenating strings and also demonstrate how to pass strings between C and Obj-C</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREObject concatenate<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> funcData<span style="color: #339933;">,</span> uint32_t argc<span style="color: #339933;">,</span> FREObject argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// To be filled</span>
    uint32_t string1Length<span style="color: #339933;">;</span>
    <span style="color: #993333;">const</span> uint8_t <span style="color: #339933;">*</span>string1<span style="color: #339933;">;</span>
    FREGetObjectAsUTF8<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>string1Length<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>string1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    uint32_t string2Length<span style="color: #339933;">;</span>
    <span style="color: #993333;">const</span> uint8_t <span style="color: #339933;">*</span>string2<span style="color: #339933;">;</span>
    FREGetObjectAsUTF8<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>string2Length<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>string2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Convert C strings to Obj-C strings</span>
    NSString <span style="color: #339933;">*</span>string1ObjC <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>NSString stringWithUTF8String<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>string1<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    NSString <span style="color: #339933;">*</span>string2ObjC <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>NSString stringWithUTF8String<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>string2<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Concat strings</span>
    NSString <span style="color: #339933;">*</span>returnString <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>string1ObjC stringByAppendingString<span style="color: #339933;">:</span>string2ObjC<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Convert Obj-C string to C UTF8String</span>
    <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>str <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>returnString UTF8String<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Prepare for AS3</span>
    FREObject retStr<span style="color: #339933;">;</span>
	FRENewObjectFromUTF8<span style="color: #009900;">&#40;</span>strlen<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">const</span> uint8_t<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>str<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>retStr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Return data back to ActionScript</span>
	<span style="color: #b1b100;">return</span> retStr<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>Boolean (AS3->C->AS3) Opposite function</h3>
<p>AS3 part:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> opposite<span style="color: #66cc66;">&#40;</span>bool:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span><span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> ret:<span style="color: #0066CC;">Boolean</span> = context.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;opposite&quot;</span>,bool<span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">Boolean</span>;
	<span style="color: #b1b100;">return</span> ret;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>C part:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREObject opposite<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> funcData<span style="color: #339933;">,</span> uint32_t argc<span style="color: #339933;">,</span> FREObject argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    uint32_t boolean<span style="color: #339933;">;</span>
    FREGetObjectAsBool<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>boolean<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    uint32_t oppositeValue <span style="color: #339933;">=</span> <span style="color: #339933;">!</span>boolean<span style="color: #339933;">;</span>
&nbsp;
    FREObject retBool <span style="color: #339933;">=</span> nil<span style="color: #339933;">;</span>
    FRENewObjectFromBool<span style="color: #009900;">&#40;</span>oppositeValue<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>retBool<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> retBool<span style="color: #339933;">;</span>   
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Full C-part source code: <a href="http://www.flashrealtime.com/demos/ANEtutorial1/IOSExtension.m">IOSExtension.m</a><br />
Download <a href="http://www.flashrealtime.com/demos/ANEtutorial1/IOSExtension.zip">whole C-project</a> for Xcode</p>
<p>Complete AS3 SWC lib part: <a href="http://www.flashrealtime.com/demos/ANEtutorial1/IOSExtension.as">IOSExtension.as</a></p>
<p>Test project source (SWF/IPA): <a href="http://www.flashrealtime.com/demos/ANEtutorial1/IOSExtensionTest.as">IOSExtensionTest.as</a></p>
<p>For compiling native extension (*.ane) I use this command in Terminal.app. </p>
<p><b>compileExtension.sh</b> file/script</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">unzip <span style="color: #339933;">-</span>o IOSExtension.<span style="color: #202020;">swc</span>
&nbsp;
<span style="color: #339933;">/</span>PATH<span style="color: #339933;">/</span>TO<span style="color: #339933;">/</span>FLEX_AIR_SDK<span style="color: #339933;">/</span>bin<span style="color: #339933;">/</span>adt <span style="color: #339933;">-</span>package <span style="color: #339933;">-</span>target ane IOSExtension.<span style="color: #202020;">ane</span> extension.<span style="color: #202020;">xml</span> <span style="color: #339933;">-</span>swc IOSExtension.<span style="color: #202020;">swc</span> <span style="color: #339933;">-</span>platform iPhone<span style="color: #339933;">-</span>ARM library.<span style="color: #202020;">swf</span> libIOSExtension.<span style="color: #202020;">a</span></pre></div></div>

<p><b>extension.xml</b> looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;extension</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/air/extension/2.5&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.krcha.IOSExtension<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;versionNumber<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/versionNumber<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;platforms<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;platform</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;iPhone-ARM&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;applicationDeployment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nativeLibrary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>libIOSExtension.a<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nativeLibrary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;initializer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ADBEExtInitializer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/initializer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;finalizer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ADBEExtFinalizer<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/finalizer<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/applicationDeployment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/platform<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/platforms<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/extension<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flashrealtime.com/transfer-string-number-int-uint-bool-ane/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: @FlashGen @chrisjeffgames sure thing, write me to tomkr at adobe … cheers</title>
		<link>http://twitter.com/tomkrcha/statuses/166909017908715520</link>
		<comments>http://twitter.com/tomkrcha/statuses/166909017908715520#comments</comments>
		<pubDate>Tue, 07 Feb 2012 15:39:45 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166909017908715520</guid>
		<description><![CDATA[tomkrcha: @FlashGen @chrisjeffgames sure thing, write me to tomkr at adobe … cheers]]></description>
			<content:encoded><![CDATA[tomkrcha: @FlashGen @chrisjeffgames sure thing, write me to tomkr at adobe … cheers]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/07/tomkrcha-flashgen-chrisjeffgames-sure-thing-write-me-to-tomkr-at-adobe-%e2%80%a6-cheers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: @cspelsor you have nordic lights instead :) that&#8217;s way more magical!</title>
		<link>http://twitter.com/tomkrcha/statuses/166880449967292417</link>
		<comments>http://twitter.com/tomkrcha/statuses/166880449967292417#comments</comments>
		<pubDate>Tue, 07 Feb 2012 13:46:14 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166880449967292417</guid>
		<description><![CDATA[tomkrcha: @cspelsor you have nordic lights instead :) that's way more magical!]]></description>
			<content:encoded><![CDATA[tomkrcha: @cspelsor you have nordic lights instead :) that's way more magical!]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/07/tomkrcha-cspelsor-you-have-nordic-lights-instead-thats-way-more-magical/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: TODO before breakfast, compile lot of stuff, write an article, go jogging and drink a black tea.Love these early mornings in US with sunrise</title>
		<link>http://twitter.com/tomkrcha/statuses/166877025703964673</link>
		<comments>http://twitter.com/tomkrcha/statuses/166877025703964673#comments</comments>
		<pubDate>Tue, 07 Feb 2012 13:32:38 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166877025703964673</guid>
		<description><![CDATA[tomkrcha: TODO before breakfast, compile lot of stuff, write an article, go jogging and drink a black tea.Love these early mornings in US with sunrise]]></description>
			<content:encoded><![CDATA[tomkrcha: TODO before breakfast, compile lot of stuff, write an article, go jogging and drink a black tea.Love these early mornings in US with sunrise]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/07/tomkrcha-todo-before-breakfast-compile-lot-of-stuff-write-an-article-go-jogging-and-drink-a-black-tea-love-these-early-mornings-in-us-with-sunrise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: Touch down in San Francisco with @mcorlan. The fun begins&#8230;</title>
		<link>http://twitter.com/tomkrcha/statuses/166766461262643200</link>
		<comments>http://twitter.com/tomkrcha/statuses/166766461262643200#comments</comments>
		<pubDate>Tue, 07 Feb 2012 06:13:17 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166766461262643200</guid>
		<description><![CDATA[tomkrcha: Touch down in San Francisco with @mcorlan. The fun begins...]]></description>
			<content:encoded><![CDATA[tomkrcha: Touch down in San Francisco with @mcorlan. The fun begins...]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/07/tomkrcha-touch-down-in-san-francisco-with-mcorlan-the-fun-begins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: We have managed to sit together with @mcorlan for the second try flight. Now the serious adventure begins, I guess :) #LufthansaSFO</title>
		<link>http://twitter.com/tomkrcha/statuses/166580911234748417</link>
		<comments>http://twitter.com/tomkrcha/statuses/166580911234748417#comments</comments>
		<pubDate>Mon, 06 Feb 2012 17:55:58 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166580911234748417</guid>
		<description><![CDATA[tomkrcha: We have managed to sit together with @mcorlan for the second try flight. Now the serious adventure begins, I guess :) #LufthansaSFO]]></description>
			<content:encoded><![CDATA[tomkrcha: We have managed to sit together with @mcorlan for the second try flight. Now the serious adventure begins, I guess :) #LufthansaSFO]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/06/tomkrcha-we-have-managed-to-sit-together-with-mcorlan-for-the-second-try-flight-now-the-serious-adventure-begins-i-guess-lufthansasfo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: RT @mcorlan: My friend @tomkrcha decided to try Lufthansa for the 1 time. Next thing the plane breaks. Czech luck I guess :D</title>
		<link>http://twitter.com/tomkrcha/statuses/166568439501160449</link>
		<comments>http://twitter.com/tomkrcha/statuses/166568439501160449#comments</comments>
		<pubDate>Mon, 06 Feb 2012 17:06:25 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166568439501160449</guid>
		<description><![CDATA[tomkrcha: RT @mcorlan: My friend @tomkrcha decided to try Lufthansa for the 1 time. Next thing the plane breaks. Czech luck I guess :D]]></description>
			<content:encoded><![CDATA[tomkrcha: RT @mcorlan: My friend @tomkrcha decided to try Lufthansa for the 1 time. Next thing the plane breaks. Czech luck I guess :D]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/06/tomkrcha-rt-mcorlan-my-friend-tomkrcha-decided-to-try-lufthansa-for-the-1-time-next-thing-the-plane-breaks-czech-luck-i-guess-d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tomkrcha: @kruszczynski yeah, that&#8217;s positive :)</title>
		<link>http://twitter.com/tomkrcha/statuses/166567647989862400</link>
		<comments>http://twitter.com/tomkrcha/statuses/166567647989862400#comments</comments>
		<pubDate>Mon, 06 Feb 2012 17:03:16 +0000</pubDate>
		<dc:creator>Tom Krcha</dc:creator>
				<category><![CDATA[tweets]]></category>

		<guid isPermaLink="false">http://twitter.com/tomkrcha/statuses/166567647989862400</guid>
		<description><![CDATA[tomkrcha: @kruszczynski yeah, that's positive :)]]></description>
			<content:encoded><![CDATA[tomkrcha: @kruszczynski yeah, that's positive :)]]></content:encoded>
			<wfw:commentRss>http://lifeasanevangelist.com/2012/02/06/tomkrcha-kruszczynski-yeah-thats-positive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

