Presentation is loading. Please wait.

Presentation is loading. Please wait.

I Made a Native Extension…and You Can Too

Similar presentations


Presentation on theme: "I Made a Native Extension…and You Can Too"— Presentation transcript:

1 I Made a Native Extension…and You Can Too
Ryan Schaefer, Monster Media

2 AIRXBC Demo

3 AIRXBC and Extension Benefits
Playing with a controller is a step towards console-quality gaming experience More immersive than traditional, casual web game experience Attract the core-gamer demographic Extended / Native Capabilities Gains beyond performance Example: in-app purchase, Game Center integration, ad networks Unique gameplay opportunities AIRKinect LEAP

4 Desktop vs. Mobile ANE Development
Mobile (iOS/Android) Info readily available on the web Loads of resources and tutorials to get started Prepackaged solutions for purchase Airextensions.net Milkman Games Desktop – To Boldly Go Where No Dev Has Gone Before... Difficult to find tutorials or examples Most helpful resource: Adobe's Docs

5 The Prime Directive: Give Others a Place to Start!
Creating a Windows extension (dll) using Visual Studio 2010 Express Make it so!

6 Setting Up the Visual Studio Project

7 Setting Up the Visual Studio Project

8 Behold: An Empty Project

9 Extension and Include Files
Must add FlashRuntimeExtensions.h and FlashRuntimeExtensions.lib from the Flex SDK Add .h file to the headers folder (right click → Add → existing item...) Add .lib file to project (right click → Add → existing item...) Add your extension header to the Header Files folder (NativeAdd.h) Right click → Add → New Item → Header File Add your extension source file to the Source Files folder (NativeAdd.cpp) Right click → Add → New Item → C++ File

10 FlashRuntimeExtensions.h
NativeAdd.h NativeAdd.cpp FlashRuntimeExtensions.lib

11 Coding the Header File

12 Working with FRE Objects
Extracting FREObject to C types: FREResult FREGetObjectAsInt32 ( FREObject object, int32_t *value ) FREResult FREGetObjectAsUint32 ( FREObject object, uint32_t *value ); FREResult FREGetObjectAsDouble ( FREObject object, double *value ); FREResult FREGetObjectAsBool ( FREObject object, uint32_t *value ); Creating FREObject from C types: FREResult FRENewObjectFromInt32 ( int32_t value, FREObject *object ); FREResult FRENewObjectFromUint32( uint32_t value, FREObject *object ); FREResult FRENewObjectFromDouble ( double value, FREObject *object ); FREResult FRENewObjectFromBool ( uint32_t value, FREObject *object );

13 Working with FRE Objects - Strings
Extracting FREObject to C types: FREResult FREGetObjectAsUTF8 ( FREObject object, uint32_t* length, const uint8_t** value) Creating FREObject from C types: FREResult FRENewObjectFromUTF8 ( uint32_t length, const uint8_t* value, FREObject* object)

14 Working with FRE Objects - Objects
FREResult FRENewObject( const uint8_t* className, uint32_t argc, FREObject argv[], FREObject* object, FREObject* thrownException )

15 Working with FRE Objects - Bitmaps
FREResult FREAcquireBitmapData( FREObject object, FREBitmapData* descriptorToSet) FREResult FREReleaseBitmapData( FREObject object ) YOU MUST RELEASE THE BITMAP DATA! No other API methods may be called until you do

16 Coding the Source File

17 The doAdd Method

18 Context Initializer and Finalizer

19 Extension Initializer and Finalizer

20 Initializers and Finalizers
Extension: Initializer is called the first time createExtensionContext is called from AS3. Finalizer is called when the program unloads the extension; may not always be called. Should clean up data/resources used by the extension. Context: Initializer is called each time createExtensionContext is called from AS3. Finalizer is called when dispose is called from AS3, when the context is garbage collected or when the AIR application shuts down.

21 The DLL is Created!

22 4 Files Needed 1) DLL 2) Description XML 3) SWC 4) SWF

23 Extension Description XML

24 Meanwhile, in ActionScript 3...

25 Generate SWC with AIR Component Compiler (acompc)
Command line or batch file acompc located in Flex SDK bin directory

26 Gathering the Files Create a directory in the Flex SDK bin folder, put all extension files there library.swf needs to be extracted from swc file

27 Packaging the ANE Navigate to Flex SDK bin directory to run

28 ANE Generated, Demo Time!

29 The End Website: @Rhuno


Download ppt "I Made a Native Extension…and You Can Too"

Similar presentations


Ads by Google