SWZ, RSL and Flexmojos Build Setup

With default Flexmojo build setup your clients may easily fall into .swz load issue. Why clients? Because you already have .swz files cached in your player but they dont. Sure, you can turn off caching easily. The issue is textLayout and osmf uses a different version numbering and .swz location than the rest of the flex sdk .swzs. The exception by flex application may look something like this:

Error #2032: Stream Error. URL: http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/textLayout_4.1.0.16076.swz
Error #2032: Stream Error. URL: http://fpdownload.adobe.com/pub/swz/flex/4.1.0.16076/osmf_4.1.0.16076.swz

Read the rest of this entry »

Getting hands dirty with molehill

Few weeks ago I played with molehill and Away3D engine. Creating 3D scene is straightforward with an engine, but I still wanted to get deeper inside and understand the low level api and agal. So I took another approach and created pure molehill version of 3ddm. Soon I realized that I have been already familiar with some procedures from drawTriangles version so I could easily use algorithm for defining vertices, indices and uv.

Read the rest of this entry »

Universal Application To Module Api

While working on my latest project, I was supposed to came up with some elegant solution (api) to make 3rd party modules be able to communicate with the main application and vice versa. In fact I already did the approach some time ago, now it was time to improve it and implement into a flex framework.

The api is based on event dispatching. Instead of sharing interface and calling some public available functions / callbacks (requires functions defined in compile time), event based api gives you the freedom of registering and releasing listeners anytime in runtime…

Read the rest of this entry »

Quick Tip: Debugging Module Inside Non-debug Application

Did you know that it is not possible to debug loaded content within release (non-debug) build app? Every attempt to insert a breakpoint during the runtime will cause null pointer exception thrown by flash builder, however you can still trace() output. To be more specific, imagine you have main application deployed somewhere on the web and you want to debug a module you are just developing wrapped inside the main application. Sure you can use proxy mapping trick + custom run configuration, that would help you run your debugging version of module.swf, however while the main application is non-debug version, the flash builder debugger will just not work correctly. Luckily you have two options to make it work. First, you may also map the main application .swf file for your debug version (+ some flex rsl files) or second option, make the flash player wrap whole content into some .swf compiled in debug mode using PreloadSWF in mm.cfg.

Read the rest of this entry »

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.