Nov 11

Determine iOS device type with ActionScript 3.0

Since I couldn’t find any articles offering the following solution to the problem of figuring out what specific iOS device an AIR app is running on I figured I’d post this short one.

For a current project I need to know what version of the iPad an AIR app is running on. I saw solutions measuring screen resolutions to get info whether an app runs in iPhone or iPad, but no posts on differentiating between iPad 1 and iPad 2. The Capabilities class seems to have the solution. Below is the output of the

property for the iPhone 4, iPad 1 and iPad 2.

iPhone 4 gives you:
iPhone OS 5.0 iPhone3,1

iPad 1 gives you:
iPhone OS 4.2.1 iPad1,1

iPad 2 gives you:
iPhone OS 5.0 iPad2,1

This info breaks down into:

  • The OS (the name apparently always is iPhone OS) with it’s version number (the iPad one in my case still running iOS 4)
  • The device id which holds the device name and the device ID

The device name and its ID apparently are different as for example the System Status reports. System Status for instance has “iPhone 4″ listed as being the Device and “iPhone3,1″ as the Device ID. The device IDs for the iPad are more descriptive, but once you know what to look for it does not really matter what it lists I guess…

Anyone have the info for the iPhone 3?

Oct 11

GPU accelerated rendering with Starling

A note to myself: I need to experiment with GPU accelerated rendering. Really…

With the new GPU rendering capabilities of Flash player 11 and AIR 3, which go under the name Stage3D (formerly known as MoleHill) performance should be greatly improved in … some, all(?) cases. Since it has been a long time I did anything with actual 3D modeling, the logical place to start is 2D. Dreading the complexity of the Stage3D API’s I will focus on the Starling framework. There is a nice example of what complexity Starling hides from you on the Adobe devnet pages. The following links will be my first information providers while experimenting I guess.

Of course the Starling API documentation.

Also: Lee Brimelow has two video tutorials on his gotoAndLearn site. One introducing the Starling framework and one explaining how to use particles in the Starling framework with one by one design’s particle editor. Lee will also host a workshop at Flash in the Can Amsterdam 2012.

The framework was written by the Austrian Gamua, also responsible for the sparrow framework for objective-C (another thing which desperately needs being looked in to) which in it’s turn is loosly based on the Flash display list API.

If you wonder why a separate library is needed in stead of using the standard display list, the following article explains why Starling is a good idea for 2D GPU rendered content.

Apr 11

Random and constrained circular motion

For a small project in the near future I could need some objects to move fairly random, but constrained to a specific area. After a quick look on the web I thought of something I read before but could not find anymore. It involves movement aided by two circles and is (IMHO) really easy to grasp. Here’s a quick explanation.

Imagine (if you can’t, there a picture below doing it for you) one circle in the middle. OK, now imagine another circle centered on the edge of the first. This second circle moves over the circumference of the first, thus describing a circular motion. Now place something on the edge of the second circle and have it move over it’s circumference. Depending on the size of the circles and the rotation speeds the object on the outer circle describes a lot of different motions looking a bit like a spirograph.

The two circles and the moving object (blue)

In the above image, the red circle is the first one. The green one moves over the circumference of the red one. The blue dot moves over the circumference of the green circle. It cannot get outside of the blue circle.

This however is a very regular motion. Not what I had in mind or promised you with the title of this post. There’s no long explanation to it, so I’ll get to it right away: To make the motion random, just have the direction of both the rotations alter at random intervals. Not to often or the final object moves in a jittery fashion (and may not even leave it’s position), not to few or the object moves to predictable. In the example below you can alter the frequency of the direction change as well as the speed of rotation (with thanks to

Get Adobe Flash player

Right-click on the flash file to view the source files.