125000 Triangles & Still Smooth

A few months ago I played with an idea of creating 3D illusion from an image and its depth map. First versions were based on displacement maps (custom implementation in pixel bender) and later I used common 3D engines to transform image into a 3D model. With software rendering I hit fps limit somewhere around 10000 triangles, what is like 70×70 segments per plane. Now if your source image is something like 700×700 pixles, the fragmentation is 10px per segment, that is not enough details for me :-) .

Luckily, Adobe introduced Molehill a GPU-accelerated 3D API and I was curious about where the limits of this are. While Away3D already released its molehill version, I have transformed existing 3ddm Away3D version what literally was just like 10 lines of code.

Read the rest of this entry »

Quick Tip: Constructor Of Property With Namespace

Some of you may not like the solution (including me) but sometimes you need a little hack to make things work for you. In my case I required a constructor of property declared under custom namespace but not defined (null). Normally, you would go for describeType(), but guess what, yeah it just does not describes properties with namespace other than public. While there was nothing better in my mind than passing some unexpected value and expect what happend I decided to go for it. Luckily an exception was thrown with correct constructor name.

Read the rest of this entry »

Simple Modular Robotlegs

You know it, when you learn new things looking for documentation or tutorials all over the internet and even if you find potential good source it is some times difficult to focus on the key information while it contains a lot of stuff you do not need at all? Well, there really are some interesting sources for building robotlegs with modules (Modular Robotlegs, DynModules, Modular Tutorial ) but it took me some time to grab only the key functionality. So, I have decided to create the simpliest working project using robotlegs and modules.

Read the rest of this entry »

The Ultimate Resource Manager

How would you like your resousrce manager to be able to access bundle content as easy as RM.bundleName.resourceName no functions used, no parameters, even better with a binding enabled? You like it? Me too. Lets have a look at the implementation.

First we need dynamic variables to be bindable. There are more existing and working solutions for this based on Proxy class. We have to handle getProperty() method and implement IEventDispatcherin order to dispatch events. The final class may looks something like BindableDynamics.

Next, lets do some ResourceManager magic to obtain localized values for our dynamic properties. We do not expect the properties will dispatch changes within one locale, but when locale changes (e.g. switch from en_US to fr_FR) all properties should get updated. A single artificial “propertyChange” event will do a good job for us. Lets call this DynamicResourceManager.

Final step can be custom. For example I like implementation with static (no initialization required) constants (constant works with mxml binding without throwing a warning) that looks something like…

Read the rest of this entry »

Faster floor, round, ceil for ActionScript

It is always nice to add some speed boost to your performance critical algorithms. Making some native Math function’s alternatives perform up to 8 times faster is possible. Lets have a look at the basic ones Math.floor(), Math.round(), Math.ceil():

faster alternative for Math.floor()

var ni:int = n;
return (n < 0 && n != ni) ? ni - 1 : ni;

faster alternative for Math.round()

return n < 0 ? n + .5 == (n | 0) ? n : n - .5 : n + .5;

faster alternative for Math.ceil()

var ni:int = n;
return (n >= 0 && n != ni) ? ni + 1 : ni;

Read the rest of this entry »

Quick Tip: Compression in Flash

While working on one of my projects where I needed compression for transfered data, I hit some very interesting compression libraries. Also the ByteArray class contains compress method, using zlib algorithm in flash player or multiple algorithms in AIR. At the end I decided to use ByteArray.compress() method for encoding vs. PHP gzuncompress for decoding, what works correctly, fast and smooth.

Here is a list of 3rd party compression libraries and other good stuff:

  • AS3 Zip: ActionScript 3 based library for reading and writing zip files
  • FZip: FZip is an Actionscript 3 class library to load, modify and create standard ZIP archives.
  • ASZip: ActionScript 3 library to generate ZIP files
  • LZMA Encoder: AS3 class to compress data using LZMA algorithm.
  • LZMA Decoder: A part of the apparat framework.
  • GZIP: ActionScript GZIP compression library
  • Gzip for HTTPService/URLLoader: Adding Gzip support for Flex/AIR HTTPService/URLLoader
  • airxzip: Zip library for ActionScript3 on AIR

If you know some more, please let me know.

Using Metadata Frame for a Preloader

This article was sleeping in my drafts for a while, and I am happy I managed to finish it today. There are multiple ways to create preloader for your ActionScript applications with flex compiler. The easiest and my prefered way is to use Frame metadata.

This metadata is a hint to the compiler that the class containing the metadata would like to be bootstrapped by the cited factory. In other words, when you build an application based on mx.core.Application, that isn’t actually the “root” class of the SWF. The root class is actually a compiler-generated subclass of mx.managers.SystemManager (Modular Applications)

Read the rest of this entry »

Quick Tip: ApplicationUpdater for Updating AIR Executables

Few days ago I red an interesting article about Auto update for Adobe Air executable. This article is pretty self-explanatory, it is important to notice, you have to use ApplicationUpdater instead of ApplicationUpdaterUI that was designed for .air apps. One thing I was missing there was to make the process even more dynamic by reading the update url from an update.xml file. Long story short here is a piece of code doing exact the thing:

// var updater:ApplicationUpdater;
var xml:XML = updater.updateDescriptor;
var ns:Namespace = xml.namespace();
var request:URLRequest = new URLRequest(xml.ns::url);
navigateToURL(request);

Read the rest of this entry »

Quick Tip: Debugging BlackBerry on Flash Builder 4

After successful installing Playbook simulator and BlackBerry Air SDK, you may wonder how to deploy your app on simulator. Now you have 2 choices. You can use command line and run something like this:

blackberry-airpackager -package -installApp -launchApp -device 192.168.44.129 MyApp.bar src/MyApp-app.xml -C bin-debug MyApp.swf icons/90x90.png blackberry-tablet.xml

… this command compiles .swf file into .bar file and installs on simulator. If you prefer click-and-deploy solution, just go into folder with your blackberry sdk:

.../sdks/blackberry-tablet-sdk-0.9.1/eclipse_for_FB401

and copy all content into your flash builder / eclipse directory.

.../Adobe/Adobe Flash Builder 4

Read the rest of this entry »

SystemMouse Moves And Clicks In Your System

SystemMouse is a class I managed to create for Remotair demo receiver, in order to show how can remote MouseEvent-s be projected into system. Long story short, you can use moveBy() function to move the system cursor and event() function to make clicks. The class is based on NativeProcess. The NativeProcess class and its capabilities are only available to AIR applications installed with a native installer (extended desktop profile applications) means .exe/.dmg file.

Read the rest of this entry »

Get Adobe Flash player