<?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>deleteaso &#187; ActionScript3</title>
	<atom:link href="http://deleteaso.com/category/actionscript3/feed/" rel="self" type="application/rss+xml" />
	<link>http://deleteaso.com</link>
	<description>When something's not working delete aso files</description>
	<lastBuildDate>Tue, 25 Oct 2011 13:32:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Creating AIR Native Extensions for BlackBerry PlayBook</title>
		<link>http://deleteaso.com/creating-air-native-extensions-for-blackberry-playbook/</link>
		<comments>http://deleteaso.com/creating-air-native-extensions-for-blackberry-playbook/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 13:32:42 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[PlayBook]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[ANE]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[playbook]]></category>

		<guid isPermaLink="false">http://deleteaso.com/?p=280</guid>
		<description><![CDATA[The PlayBook NDK 1.0 was released at BlackBerry DevCon Americas 2011 this week and with it comes the ability to create AIR Native Extensions. AIR Native Extensions is one of the big features available in AIR 3.0 on all other platforms. However, Native Extensions have been available in the AIR Runtime on the PlayBook since [...]]]></description>
			<content:encoded><![CDATA[<p>The PlayBook NDK 1.0 was released at BlackBerry DevCon Americas 2011 this week and with it comes the ability to create AIR Native Extensions. AIR Native Extensions is one of the big features available in AIR 3.0 on all other platforms. However, Native Extensions have been available in the AIR Runtime on the PlayBook since it launched. So when developing your application and your ANE, it is not necessary to target AIR 3.0. You can target AIR 2.7 and the BlackBerry Tablet OS 1.0.7 if you like.</p>
<h2>Pre-requisites</h2>
<p>In order to create an ANE you will need to download and install the following tooling.</p>
<p><strong>PlayBook NDK 1.0</strong> &#8211; <a href="https://bdsc.webapps.blackberry.com/native/" target="_blank">https://bdsc.webapps.blackberry.com/native/</a><br />
Once installed, this is what you will use to develop the native portion of our ANE.</p>
<p><strong>Flash Builder 4.6</strong> public pre-release – <a href="http://adobe.ly/qGRD3d" target="_blank">http://adobe.ly/qGRD3d</a><br />
The current release version of Flash Builder, 4.5.1, does not contain support for ANE development. It is possible to use it with lots of work arounds, but it is better to simply sign up for the pre-release of 4.6.</p>
<p>Currently Flash Builder 4.6 only comes with the Flex 4.6 SDK, which requires you to have AIR 3.1, even if you are only creating an ActionScript project. So to get around this, I would recommend copying the 4.5.1 SDK from your Flash Builder 4.5/sdks folder before un-installing it and installing Flash Builder 4.6. This will allow you to develop ANE’s and target AIR 2.7.</p>
<p>Or you can download the latest Flex 4.5.1 SDK from the Flex open source site here. <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.5 " target="_blank">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4.5 </a>You will then need to download the AIR SDK and overlay it on top of the Flex SDK.<br />
AIR SDK download &#8211; <a href="http://www.adobe.com/special/products/air/sdk/" target="_blank">http://www.adobe.com/special/products/air/sdk/</a><br />
Overlay instructions &#8211; <a href="http://kb2.adobe.com/cps/495/cpsid_49532.html" target="_blank">http://kb2.adobe.com/cps/495/cpsid_49532.html</a></p>
<p>Hopefully that wasn’t too painful to get up and running and as more of these tools get officially released it will become easier.</p>
<p>Source code for the native and ActionScript implementations as well as a sample application can be downloaded <a href="http://deleteaso.com/downloads/anetutorial.zip">here</a>.</p>
<h2>Developing the native library</h2>
<p>Before you can start coding the native side there are a couple of things that are required in order to set up your project correctly.</p>
<p>First create a new project.<br />
<strong>File &gt; New &gt; BlackBerry Tablet OS C/C++ Project</strong></p>
<p><strong><img class="alignnone" title="new project" src="http://deleteaso.com/images/anetutorial/newproject.png" alt="" width="600" height="400" /><br />
</strong></p>
<p>After you create name for you project you will be asked to select what type of project to create.  Make sure to select <strong>Shared Library  &gt; Empty Project</strong>.</p>
<p><img class="alignnone" title="shared library" src="http://deleteaso.com/images/anetutorial/sharedlibrary.png" alt="" width="600" height="517" /></p>
<p>When you press Finish your project will be created. Once created select <strong>Project &gt; Properties</strong>.</p>
<p>The Project Properties dialog is presented and we need to add the AirStub library to your build configuration.<br />
<strong>1.	Select C/C++ Build &gt; Settings from the left menu.</strong><br />
<strong> 2.	Select QCC Linker &gt; Libraries</strong><br />
<strong> 3.	Click the “+” Button in the Libraries Section.</strong><br />
<strong> 4.	Enter “AirStub” into the prompt.</strong></p>
<p><strong><img class="alignnone" title="air stub" src="http://deleteaso.com/images/anetutorial/airstub.png" alt="" width="600" height="483" /><br />
</strong></p>
<p>You will need to do this to every Build Configuration you plan on using. To add the AirStub library to another configuration, select it from the Configuration drop down at the top of the dialog.</p>
<p>With that your project is ready to start coding. Create a new Source File and name it main.c, or something similar.</p>
<p>Throughout this article I will explain some of the native code, as we show some simple examples of how to interact with native code. For more information on all of the C methods read through the documentation on Adobe’s web site. <a href="http://help.adobe.com/en_US/air/extensions/index.html" target="_blank">http://help.adobe.com/en_US/air/extensions/index.html</a></p>
<p>You can also look through the FlashRuntimeExtensions.h header file to find all of the methods and properties.</p>
<p>I have attached a sample project that with this article and in the next section will explain the pieces of it.</p>
<h2>Initializing the extension</h2>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> ExtInitializer<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">**</span> extDataToSet<span style="color: #339933;">,</span> FREContextInitializer<span style="color: #339933;">*</span> ctxInitializerToSet<span style="color: #339933;">,</span>
FREContextFinalizer<span style="color: #339933;">*</span> ctxFinalizerToSet<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #339933;">*</span>extDataToSet <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
<span style="color: #339933;">*</span>ctxInitializerToSet <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>ContextInitializer<span style="color: #339933;">;</span>
<span style="color: #339933;">*</span>ctxFinalizerToSet <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>ContextFinalizer<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The ExtInitializer method is called when your extension is initialized by your application. The method can be called whatever you want and is defined later on. However, the method signature must match the FREInitializer(). For more info check out the documentation here<a href="http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b141a93a0d1129383bfc42-8000.html"> http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b141a93a0d1129383bfc42-8000.html</a></p>
<p>This method sets pointers to the ContextInitializer and ContextFinalizer methods. Next let’s have a look at the ContextInitializer.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> ContextInitializer<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span> extData<span style="color: #339933;">,</span> <span style="color: #993333;">const</span> uint8_t<span style="color: #339933;">*</span> ctxType<span style="color: #339933;">,</span>
FREContext ctx<span style="color: #339933;">,</span> uint32_t<span style="color: #339933;">*</span> numFunctionsToSet<span style="color: #339933;">,</span>
<span style="color: #993333;">const</span> FRENamedFunction<span style="color: #339933;">**</span> functionsToSet<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #993333;">static</span> FRENamedFunction s_classMethods<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #009900;">&#123;</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><span style="color: #ff0000;">&quot;helloNative&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> helloNative<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</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><span style="color: #ff0000;">&quot;getElementAt&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> getElementAt<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</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><span style="color: #ff0000;">&quot;updateBitmap&quot;</span><span style="color: #339933;">,</span> NULL<span style="color: #339933;">,</span> updateBitmap<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">const</span> <span style="color: #993333;">int</span> c_methodCount <span style="color: #339933;">=</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>s_classMethods<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>FRENamedFunction<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Update caller with the required data</span>
<span style="color: #339933;">*</span>functionsToSet <span style="color: #339933;">=</span> s_classMethods<span style="color: #339933;">;</span>
<span style="color: #339933;">*</span>numFunctionsToSet <span style="color: #339933;">=</span> c_methodCount<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Your context initializer method can be called anything as long as it matches the FREContextInitializer(). For more information have a look at the documentation here.<br />
<a href="http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-7ffd.html">http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-7ffd.html</a></p>
<p>The purpose of this method is to set up a mapping to all of your methods that will be called from ActionScript. In our example we have 3 methods, helloNative, getElementAt, and updateBitmap. The first argument in the  s_classMethods elements is the string that will be used to call the method from ActionScript. You will see how this works later on when we look at developing the ActionScript side.</p>
<p>The third argument is a reference to the native method. Although these 2 names can be different, it is best practice to keep them the same.</p>
<p>Once your methods are defined, update the pointers that where passed in to the function with the methods and the method count.</p>
<p>Before we look at the implementation of the native methods lets quickly take a look at the finalizer methods.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">void</span> ContextFinalizer<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>When your extension context is unloaded the above method will be called. This is the opportunity to do any cleanup and dispose of any objects in your extension.</p>
<h2>Creating native methods</h2>
<p>Now that our methods are defined in our context initializer let’s create the native methods. All of the methods need to have the same method signature – FREFunction() &#8211; <a href="http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-7ffa.html">http://help.adobe.com/en_US/air/extensions/WSb464b1207c184b14-62b8e11f12937b86be4-7ffa.html</a></p>
<p>Here is what our helloNative method looks like.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREObject helloNative<span style="color: #009900;">&#40;</span>FREContext ctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span><span style="color: #339933;">*</span> functionData<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: #339933;">;</span></pre></div></div>

<p>The first argument, FREContext ctx, is the context of the extension.<br />
The second argument, void* functionData, is native data passed to the method. When setting up a mapping of the methods in the context initializer, the second parameter of the object was NULL. You could have created some data and had it passed in as this argument to our function.<br />
The third argument, uint32_t argc, is the number of arguments passed from ActionScript.<br />
The fourth argument, FREObject argv[], is an array of all the arguments passed from ActionScript.</p>
<p>The FREObject represents any ActionScript object of any data type. Every object passed from ActionScript will be of this type and every object returned from native to ActionScript must be of this type. You can see that the method signature for the method returns an FREObject. It is up to the native code to convert an FREObject into a native data type so it can work with it. Fortunately there are a number of methods to help with this. Here is a list of them and based on the name it should be fairly straightforward what does what.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">FREGetObjectAsInt32 <span style="color: #009900;">&#40;</span> FREObject object<span style="color: #339933;">,</span> int32_t  <span style="color: #339933;">*</span>value <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
FREGetObjectAsUInt32<span style="color: #009900;">&#40;</span> FREObject object<span style="color: #339933;">,</span> uint32_t <span style="color: #339933;">*</span>value <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
FREGetObjectAsDouble<span style="color: #009900;">&#40;</span> FREObject object<span style="color: #339933;">,</span> <span style="color: #993333;">double</span>   <span style="color: #339933;">*</span>value <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
FREGetObjectAsBool  <span style="color: #009900;">&#40;</span> FREObject object<span style="color: #339933;">,</span> uint32_t <span style="color: #339933;">*</span>value <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
FREGetObjectAsUTF8<span style="color: #009900;">&#40;</span> FREObject object<span style="color: #339933;">,</span> uint32_t<span style="color: #339933;">*</span> length<span style="color: #339933;">,</span><span style="color: #993333;">const</span> uint8_t<span style="color: #339933;">**</span> value <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Suppose the first argument passed into your method was an int. You would do the following to convert the value.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">int32_t index<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>amp<span style="color: #339933;">;</span>index <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Setting a native data type to an FREObject to return to ActionScript is pretty much the same, but the reverse. You can see an example of this in the implementation of the helloNative method.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>out <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Hello Native<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
FREObject result<span style="color: #339933;">;</span>
FRENewObjectFromUTF8<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>uint32_t<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>strlen<span style="color: #009900;">&#40;</span>out<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>uint8_t<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> out<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>These few simple concepts are the basics for creating native methods for ActionScript to call. The getElementAt() method shows how to easily access elements in an Array using native methods. The updateBitmap() method shows how to modify a BitmapData object from ActionScript and have it re-drawn with the new values. These examples should get you started on creating the native code for your ANE.</p>
<h2>Coding the ActionScript implementation</h2>
<p>Included in the sample there is a Flash Builder 4.6 Flex Library project called firstane. This project includes the ActionScript implementation of our ANE. The FirstANE class has 3 methods that mimic our native methods. It is good practice to do this whenever possible so methods are easy to map across the 2 code bases.</p>
<h2>Creating the extension context</h2>
<p>In the constructor of the class we create a reference in ActionScript to our extension context.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">ext = ExtensionContext.createExtensionContext<span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;qnx.extensions.FirstANE&quot;</span>, <span style="color: #0033ff; font-weight: bold;">null</span> <span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>The first argument is the ID of the extension. This can be anything you like, but should be something that is unique to you. Reverse domain is always a great standard. Later in this article we’ll show where to define this.</p>
<p>The second argument is an optional context type. This is passed to the context initialization method so that the native code can initialize different implementation based on a context. Most extensions will not require this, but more complicate extensions it may be useful.</p>
<p>Once we have a reference to the extension, native methods are now available to be called. Calling native methods are really simple. If we have a look at the getElementAt() method it shows how to call a native method with arguments and return the result from the native code.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> getElementAt<span style="color: #000000;">&#40;</span> items<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Array</span>, <span style="color: #004993;">index</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">int</span> <span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>
<span style="color: #000000;">&#123;</span>
<span style="color: #0033ff; font-weight: bold;">return</span><span style="color: #000000;">&#40;</span> ext.<span style="color: #004993;">call</span><span style="color: #000000;">&#40;</span> <span style="color: #990000;">&quot;getElementAt&quot;</span>, items, <span style="color: #004993;">index</span> <span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">String</span> <span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>To call any native method the ExtensionContext.call() method is used &#8211; <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExtensionContext.html#call()">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExtensionContext.html#call()</a></p>
<p>The first parameter is the string that you used in the context initializer. This is the method that we are going to call.</p>
<p>The second and third parameters are arguments that are passed to the native method.</p>
<p>The returned value of the call() method is the value returned from the native method. Because this could be any data type, it is necessary to cast it to the type that the method is expecting.</p>
<h2>Defining the extension</h2>
<p>In the bin folder of the firstane project there is an extension.xml file. This is the file that is used to define the extension. Here is what it looks like.</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>qnx.extensions.FirstANE<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;QNX-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>libfirstane.so<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>ExtInitializer<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>ExtFinalizer<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>

<p>The  node is the root node and the version at the end must be 2.5. This value is not the same as the AIR Runtime version you are targeting. Even if your application is targeting AIR 3.0,  the extension namespace must be http://ns.adobe.com/air/extension/2.5.</p>
<p>The  node is extension id is defined. This is the same value that is passed into the ExtensionContext.createExtensionContext() method in ActionScript.</p>
<p>The  is the version number of your extension.</p>
<p>The  node is a list of  nodes that define all of the platforms the extension supports.</p>
<p>The BlackBerry PlayBook supports 2 platforms, QNX-ARM for the PlayBook hardware, and QNX-x86 for the PlayBook Simulator.</p>
<p>One thing that is a really good idea is to implement a default platform for when application runs on a platform that is not supported. For, example you may create native libraries for both the PlayBook device and simulator, but what happens when you want to test your application locally on your development machine. If the API’s only exist on the PlayBook platforms your application will not run locally on Windows or OSX. To accomplish this you can create a “default” platform that is ActionScript only. This allows you to implement default behavior for your API and allow you to fail gracefully or provide alternate implementations.</p>
<p>For more details on the extension descriptor file check out the Adobe documentation here. <a href="http://help.adobe.com/en_US/air/extensions/WS901d38e593cd1bac-3004221412afa24c001-8000.html">http://help.adobe.com/en_US/air/extensions/WS901d38e593cd1bac-3004221412afa24c001-8000.html</a></p>
<h2>Compiling the extension</h2>
<p>In order to compile the extension you must use the adt command line tool that comes with the AIR SDK.</p>
<p>First you must un-zip the firstane.swc. SWC files are simply zip files that contain a library.swf and a catalog.xml. You will need the library.swf to be compiled with each platform, and it must be named library.swf. You can dispose the catalog.xml file, as it is not needed.</p>
<p>To make life easier I have placed the firstane.so, firstane.swc, library.swf, and extension.xml all in the same directory. Here is the command to compile your ane.</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">adt –package –target ane firstane.ane extension.xml –swc firstane.swc –platform QNX-ARM –C . firstane.so library.swf</pre></div></div>

<p>For BlackBerry PlayBook ANE files it is not necessary to sign them and is optional.</p>
<h2>Using a ANE</h2>
<p>In order to use an ANE, it is best to simply follow the instructions in the Flash Builder 4.6 pre-release site. The only difference for the BlackBerry platform is an additional permission is needed in the apps blackberry-tablet.xml file.</p>
<p>run_air_native</p>
<p>Included in the source is a Flash Builder project called firstaneapp that shows how to use the application. You will most likely have to fix the path to the .ane in the project file, but it should give you an idea on how to use it.</p>
<h2>Conclusion</h2>
<p>Hopefully this gets you started in creating ActionScript Native Extensions for the BlackBerry PlayBook. All of the C API documentation from Adobe on ANE’s applies to the PlayBook. With all of the documentation out there, this article and the sample projects, hopefully it gets you well under way.</p>
]]></content:encoded>
			<wfw:commentRss>http://deleteaso.com/creating-air-native-extensions-for-blackberry-playbook/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>AS3 SVN Library</title>
		<link>http://deleteaso.com/as3-svn-library/</link>
		<comments>http://deleteaso.com/as3-svn-library/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 21:12:58 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[fuelindustries]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://deleteaso.com/?p=225</guid>
		<description><![CDATA[A few months ago I started writing a svn protocol library in as3. It started with an idea for a internal tool that would allow us to select files from our svn code repository and export it and all of it&#8217;s code dependencies. And because I haven&#8217;t done a lot of work with ByteArray, or [...]]]></description>
			<content:encoded><![CDATA[<p>A few months ago I started writing a svn protocol library in as3. It started with an idea for a internal tool that would allow us to select files from our svn code repository and export it and all of it&#8217;s code dependencies. And because I haven&#8217;t done a lot of work with ByteArray, or Sockets before I was pretty excited about giving this a shot. My first attempts where really rough and basic and worked for the most part, but were in no shape to be in the form of a nice library. I let it sit for a while as I was busy getting ready for FOTB and Flashpitt. Then one night I started doing some more research about the protocol and found that SVNKit, a Java SVN library, was open source. So I started going through all the source and spent a great deal of time going through how the code was structured. I couldn&#8217;t just do a straight port because of the differences that data gets returned between Java and AS3. Long story short the way they have it set up is you can make the call to the server and on the next line read the input. In AS3 you need to wait for your event to come back, and there is no guarantees that all of it is going to come back in one event either. But I was able to port some important parts like reading and writing the data. I&#8217;ve tried to keep the API&#8217;s similar, but there are instances where they just couldn&#8217;t be or didn&#8217;t make sense to. One of my goals for this project to is to make it as platform independent as possible. And by that I mean I want you to be able to use the library in the web, air, and any other Flash Player 10 player. I&#8217;ve tried to abstract out the parts that deal with writing files to disk so that this could be accomplished. But there may come a point where a feature may need AIR for whatever reason. But I&#8217;ll cross that bridge when I get to it. If that feature isn&#8217;t a super high priority chances are I will leave it out just for that reason.</p>
<p>That all being said I just made a fairly big commit today to the <a href="http://code.google.com/p/fuelas3svn/" target="_blank">google code repository</a>. It isn&#8217;t fully featured yet and only supports the svn:// protocol. Once I get some more of that protocol completed I plan on doing the http:// protocol. In the wiki there is an example AIR app that allows you to display directories in a tree, export files and folders, as well as trace out the log for any item in the repository. </p>
<p>This is still a work in progress and lots to do before it gets to a really stable state. For instance the Error handling is almost non-existent but I have placed a lot of //TODO where the errors need to be thrown. I also only have 1 svn server to test on so I am not sure how running it in other environments will work out. </p>
<p>I have created the library to a point where I can create our internal app, so I am not entirely sure what features I will tackle next. I may try doing commit and add, but those are fairly big. So if you have any requests I am all ears. </p>
]]></content:encoded>
			<wfw:commentRss>http://deleteaso.com/as3-svn-library/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>AS3 FP10 FileReference.save bug</title>
		<link>http://deleteaso.com/as3-fp10-filereferencesave-bug/</link>
		<comments>http://deleteaso.com/as3-fp10-filereferencesave-bug/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 23:14:45 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://deleteaso.com/?p=180</guid>
		<description><![CDATA[While playing with FileReference.save today in Flash Player 10 I found a REALLY REALLY BIG BUG. It seems that if you go to overwrite a file it appends it&#8217;s contents instead of replacing. 1. Copy and paste the code below into a blank fla in CS4. 2. Compile the swf and save a file. 3. [...]]]></description>
			<content:encoded><![CDATA[<p>While playing with FileReference.save today in Flash Player 10 I found a REALLY REALLY BIG BUG. It seems that if you go to overwrite a file it appends it&#8217;s contents instead of replacing.</p>
<p>1. Copy and paste the code below into a blank fla in CS4.<br />
2. Compile the swf and save a file.<br />
3. Close the swf<br />
4. repeat step 2<br />
5. Open the test.txt file. </p>
<p>I am on OSX and haven&#8217;t tested on a PC.</p>

<div class="wp_syntax"><div class="code"><pre class="as3" style="font-family:monospace;">var str:String = &quot;12345&quot;;
var ba:ByteArray = new ByteArray();
ba.writeUTFBytes( str );
&nbsp;
var fr:FileReference = new FileReference();
fr.save(ba, &quot;test.txt&quot;);</pre></div></div>

<p>I did a quick search on the Adobe bug base and found some related issues from 2008 but they where for downloading files from the net.</p>
]]></content:encoded>
			<wfw:commentRss>http://deleteaso.com/as3-fp10-filereferencesave-bug/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>gotoAndStop in AS3</title>
		<link>http://deleteaso.com/gotoandstop-in-as3/</link>
		<comments>http://deleteaso.com/gotoandstop-in-as3/#comments</comments>
		<pubDate>Sat, 28 Apr 2007 16:06:52 +0000</pubDate>
		<dc:creator>julian</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://deleteaso.com/gotoandstop-in-as3/</guid>
		<description><![CDATA[I have been busy re-writing our AS2 libraries to AS3 this week and encountered something that will easily trip up most people. And of course I didn&#8217;t see it in any documentation anywhere. Basically the issue is that in AS2 when you navigated to a frame using mc.gotoAndStop() you would have access to all the [...]]]></description>
			<content:encoded><![CDATA[<p>I have been busy re-writing our AS2 libraries to AS3 this week and encountered something that will easily trip up most people. And of course I didn&#8217;t see it in any documentation anywhere. Basically the issue is that in AS2 when you navigated to a frame using mc.gotoAndStop() you would have access to all the elements on that frame. But now in AS3 they aren&#8217;t available right away. I found a great post by Senocular that explains this and shows the solution. <a href="http://www.kirupa.com/forum/showpost.php?p=2113726&amp;postcount=358" target="_blank">Check out the post here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://deleteaso.com/gotoandstop-in-as3/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>

