Adobe AIR code iOS

Adobe AIR: Native Extension for files download on iOS7/8.

Recently, I spend some time on cleaning up and open-sourcing my latest Adobe Native Extension. With Background Transfer – ANE you can easily download big files to your Adobe AIR app on iOS. My native code uses Apple’s NSURLSession class which is invented to perform this download nicely:

  • download is managed by iOS;
  • the transfer continues even when the user sends the app to the background (e.g. switches to another app);
  • no time limit is set for download task;
  • if the app crashes during the download, the retransmission will start automatically when the app is launched;

Feel free to grab my ANE from GitHub:

Zrzut ekranu 2014-11-28 o 00.56.30

And don’t forget to try demo application, which you’ll find in repo.

iOS mobile objective-c

iOS7: UIAppearance and UIButton titleLabel font.

It seems that styling UIButton‘s titleLabel font with UIAppearance works differently between iOS6 and iOS7.
Here’s what works on iOS6 but is not working on iOS7:

[[UIButton appearance] setBackgroundColor:[UIColor lightGrayColor]];
[[UIButton appearance] setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[[UILabel appearanceWhenContainedIn:[UIButton class], nil] setFont:[UIFont fontWithName:@"Marker Felt" size:20]];

Above has no effect on iOS7. The solution requires a little bit more code.
Here’s what works both on iOS6 and iOS7:

[[MyCustomButton appearance] setBackgroundColor:[UIColor lightGrayColor]];
[[MyCustomButton appearance] setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[[MyCustomButton appearance] setTitleFont:[UIFont fontWithName:@"Marker Felt" size:20]];

but you have to define MyCustomButton somewhere in your theme class:

// in AppThemeClasses.h file
@interface MyCustomButton : UIButton
@property (strong, nonatomic) UIFont *titleFont UI_APPEARANCE_SELECTOR;

// in AppThemeClasses.m file
@implementation MyCustomButton
- (void)setTitleFont:(UIFont *)font {
    if (_titleFont != font) {
        _titleFont = font;
        self.titleLabel.font = font;

read more »

code physic

Projectile: initial velocity angle to hit coordinate.

While working on an aiming system for my upcoming game I faced a problem: “What should be the initial velocity angle for a projectile to hit given coordinate?”. I wanted the bullet to pass thru mouse position after it’s launched. Following image illustrates the problem:

Projectile angle to hit coordinate

I wanted the projectile (yellow square) to hit coordinate marked with red cross. Moreover, I wanted to fix the initial velocity vector length to be constant. It was intuitive for me that I’ll end up with more than one trajectory. One will hit the coordinate after reaching maximum height while another will use the shortest parabolic path. Let me share my solution with you. read more »


STEGU Catalog – mobile app with Adobe AIR.

More than a month ago I finally finished STEGU Catalog development, in cooperation with DML. This mobile app runs with Adobe AIR both on iOS and Android devices. The application gives a quick access to the full STEGU offer icluding products images and videos.

Some technical details: read more »


Copy and rename sequence of files in bash.

Today I learned an useful substring replacement construct in bash. Copy & rename with sequence of files is common task in my work. Here’s a quick way:

maciek$ ls
b_gun1_anim0000.png	b_gun1_anim0002.png	b_gun1_anim0004.png	b_gun1_anim0006.png	b_gun1_anim0008.png	b_gun1_anim0010.png	b_gun1_anim0012.png
b_gun1_anim0001.png	b_gun1_anim0003.png	b_gun1_anim0005.png	b_gun1_anim0007.png	b_gun1_anim0009.png	b_gun1_anim0011.png
maciek$ for frame in b_*anim*.png; do cp $frame ${frame/b_/c_}; done;
maciek$ ls
b_gun1_anim0000.png	b_gun1_anim0003.png	b_gun1_anim0006.png	b_gun1_anim0009.png	b_gun1_anim0012.png	c_gun1_anim0002.png	c_gun1_anim0005.png	c_gun1_anim0008.png	c_gun1_anim0011.png
b_gun1_anim0001.png	b_gun1_anim0004.png	b_gun1_anim0007.png	b_gun1_anim0010.png	c_gun1_anim0000.png	c_gun1_anim0003.png	c_gun1_anim0006.png	c_gun1_anim0009.png	c_gun1_anim0012.png
b_gun1_anim0002.png	b_gun1_anim0005.png	b_gun1_anim0008.png	b_gun1_anim0011.png	c_gun1_anim0001.png	c_gun1_anim0004.png	c_gun1_anim0007.png	c_gun1_anim0010.png
ai code

Potential Fields AI, 3/3: real game example.

Today I’ll write about my pretty advanced implementation of Pontential Fields AS3 library in upcoming game. This is the last part of Potential Fields AI article. It started with theory and basics in part 1. In part 2 you learned more about PFLib details and we implement RTS fighting bots demo. However, In near future I plan to port the library to few other languages and keep the update status on this blog.

Potential Fields real game example

Units in my game have their own attack behaviors. Zeppelins throw bombs at the target and drones attack with machine gun from right or left. Bots avoid collisions while being idle. They fly with different speed and acceleration and have various shot distances. It’s all running with my Pontential Fields AS3 library and Nape physic. Let me write about details! read more »

ai code

Potential Fields AI, 2/3: RTS bot implementation.

This is part 2 of Potential Fields AI article. In part 1 I presented you basic example of my Potential Fields AS3 library. Today we’re going to implement a game with RTS bots fighting against enemies. In part 3 I’ll describe AI details from my upcoming game.

RTS bots fighting.

Above image presents what we’re going to implement: two teams of bots fighting each other with guns. Each bot shots bullets of its own color. read more »

ai code

Potential Fields AI, 1/3: hello potentials.

Potential fields are an interesting concept in games development. I decided to use them in my upcoming title, so I created a Potential Fields AS3 library (PFLib). This library drives bots AI in my RTS engine. The game is still in development, but here’s a video showing my current results (this gonna be pretty complex defense game with bots attacking your base and fighting against your team):

In this 3-part article I’ll tell you what are potential fields and how you can use my library to create AI in your games. In this first part I’ll start with some theory and basic AI implementation. read more »

Adobe AIR code iOS

Adobe AIR: “Error #1056: Cannot create property preventBackup on flash.filesystem.File.” error fix.

Yay. I’m using Adobe AIR 3.7 merged into Flex SDK 4.6 and this error was raising on desktop and mobile at runtime. I forgot to define proper swf-version flag in my compiler settings. Here’s quick fix for FlashBuilder:

How to fix "Error #1056: Cannot create property preventBackup on flash.filesystem.File." error.

This took me about an hour, so I hope to save someone’s time.

PS. Here’s nice list of swf-versions values for different SDK configurations: -swf-versions list.