25 Feb

Admob OpenFL Extension

As I moved from Flash (Adobe Air) to OpenFL, the same I’m doing with extensions.
First extension, Admob OpenFL Extension could be installed with haxelib:

haxelib install admob-openfl

Full source code and usage instructions could be found on GitHub:
Admob OpenFL Extension

Unfortunately, extension supports only Android, so if anyone wants to add iOS support, please let me know!

ะท.ั‹.: Amazon Ads extension is coming soon… ๐Ÿ™‚

26 Aug

Loading assets from .swf with OpenFL + font embedding

A small tutorial on how to load assets from .swf file with OpenFL.

First, make sure you have the latest version of Haxe and OpenFL.
You can also execute the following command to update your libs to the latest versions:

haxelib upgrade

Second, make sure you have SWF Library, execute:

haxelib install swf

Now, we need to create our SWF library with all the assets.
You can do it with any version Adobe Flash or any other software of your choice.
Creat new flash project, import your assets to the library and make sure that every asset, you want to use, has AS Linkage.

In my example, I have one image with “button” class name:
aslinkage
You should remember class names for all the assets, you will load.
Build .swf file.

Ok, start coding.
Create new Haxe/OpenFL project with FlashDevelop (or whatever you use).
Put your .swf file into assets folder.

Open application.xml file and add the following lines:
1. our SWF Library, so we can use it:

<haxelib name=”swf” />

2. Link to our .swf file:

<library path=”assets/graphics.swf” type=”swf” />

In my case, I have graphics.swf file.
You should remember its name, as you will use it late.

Now we need to load our assets, open your .hx file, where you will load your assets (in my example, it’s Main.hx) and add the following code:

Assets.loadLibrary("graphics", onSwfLoaded); //we load our .swf file by its name "graphics"

After .swf file successfully loaded, we can start using our assets:

private function onSwfLoaded(lib:AssetLibrary):Void
{
	var bmpd:BitmapData = null;
	bmpd = Assets.getBitmapData("graphics:button"); //syntax is [SWF_FILE_NAME]:[ASSETS_CLASS_NAME]
 
	var bmp:Bitmap = new Bitmap(bmpd, PixelSnapping.AUTO);
	bmp.x = 200;
	bmp.y = 100;
	addChild(bmp);
}

The same should work for MovieClips and Sounds.
Worth mentioning, SWF Library doesn’t work for HTML5 target.

In order to embed font to you project, we need to do the following steps:
1. Put all the font files into the folder within our project, for example, “assets/fonts/“;
2. Add the following line to application.xml:

<assets path=”assets/fonts” rename=”fonts” />

3. Load and use our font:

var font:Font = Assets.getFont("fonts/arial.ttf"); //load font
var format:TextFormat = new TextFormat(font.fontName, 20, 0xffffff); //create new TextFormat with our font
var text:TextField = new TextField();
text.defaultTextFormat = format;
text.embedFonts = true; //make sure we use our loaded font
text.width = 500;
text.text = "That was easy!";
text.x = 300;
text.y = 400;
addChild(text);

If you build and run sample project, you will see the following result:
result

Sample project source code:
OpenFL_SWF_Font

Have fun! ๐Ÿ™‚

23 Apr

Rainbow Lines and etc.

Some news…

* I have released Rainbow Lines on Google Play.
I have decide to make two separate versions of the game: with HD graphics and without, otherwise game file size is too big.

* Updated AdMob ANE to comply with the latest AdMob/Google Mobile Ads/Google Play/AdSense changes. New ANE is much heavier and throws numerous warnings, but seems to work fine. ๐Ÿ™‚
Old version is deprecated and “Google Play will stop accepting new or updated apps that use the old standalone Google Mobile Ads SDK v6.4.1 or lower. You must upgrade to the Google Play version of the Mobile Ads SDK by then.”
As usual, it is available on GitHub: https://github.com/pozirk/ANEAdMob

* Match Jong is somewhat in freezed state at the moment, but I have a playable demo, and my artist is ready to start preparing graphics. Going to start working on the game soon. ๐Ÿ™‚

* Little by little, I’m releasing free version of All-in-One Mahjong 2 with updated AdMob ANE, of course.
All-in-One Mahjong 2 FREE is already available on Google Play.

04 May

Application Licensing ANE

I have published paid app on Google Play and Samsung Apps, so I have used there licensing services in order to protect the game from illegal copying (DRM).

In order to use these services with my current AIR apps, I have developed by own ANEs.
The source code along with extensions and some usage examples can be found on Github: ANE License Checker

I’m also going to publish the game on SlideME, so will add support of their licensing service later.

Luckily, Amazon and B&N has built-in protection, that is applied when you publish your app, no need to make extensions for them.

18 Feb

Adobe AIR In-app Purchase native extensions

I have spent some time searching for free extensions for all the possible platforms and would like to share my results.
Also, I made my own in-app purchase extension for Android, as I couldn’t find a good and free one.

1. In-app Purchase for Blackberry Playbook.
There is an extension that comes with BlackBerry SDK for Adobe AIR.
API docs: http://developer.blackberry.com/air/apis/playbook/net/rim/blackberry/payment/PaymentSystem.html

2. In-app Purchase for iOS.
In-app purchase extension comes with Adobe Gaming SDK

3. In-app Purchase for Amazon Kindle.
It comes with Amazon SDK: https://developer.amazon.com/sdk/in-app-purchasing/documentation/adobe.html

4. In-app Purchase for Android.
I have found two extensions:
First is free extension from Freshplanet, but it is outdated.
Second is from Milkman for $50.
So, I have decide to make my own. ๐Ÿ™‚
You can find it here: Adobe AIR In-app Purchase native extension for Android

Hope, it will help someone in its mobile app development.
Read More