
While working on my next project, I am looking for the best possible techniques to make it fastest possible (both client and server). My app requests a lot of images here and there, it may count up to hundreds or thousands requests in a while. I can not hold all of those wthin flash player cache because some of them may change, and I also want shortest possible respond times and client-server traffic reduction as well as server side computing reduction. Thats where browser caching comes into the scene. I have experimented a bit with all possible http headers to understand each browser specifics and I came with a solution.
Read the rest of this entry »

What is the usual practice when searching / setting / operating over some list of item? I think you usually think of iterating over some list (array) or linked list etc. Well, ActionScript has to offer one more technique you maybe never tought of, lets call it listener-looping. ActionScript is event based language, that means that every EventDispatcher based classes are able to listen and dispatch events. And this fits our needs for loop alternative. Lets suggest, you do not have any list to be iterated over but you still have a chance to accomplish it by making each item listening for custom event.
Read the rest of this entry »

Lets have a look at some of the most common and fastest loops used in ActionScript 3. Is int really faster than uint and Number? Is while loop faster than for? Is pre-increment faster than post-increment? To test all of these I have created benchmark test application on wonderfl. App compares loops with 10.000.000 iterations and logs testing times. To compare different variable types, loop methods, increment / decrement modes, there are buttons grouping each test. Please be patient with your first click, the model Array is being generated (Link button also generates linked list). The first test compares Arrays, second one Vectors.
Read the rest of this entry »

Few days before I saw an amazing 3d effects on VidazPhoto. That made me want to master this effect. So, starting today morning I played around with flex and pixel bender and here are the results. I have created simple pixel bender kernel that uses monochromatic bitmapData to calculate amount of displacement for each pixel. All you have to do, in order to make your 2D images become 3D, is to create monochromatic map (black & white image) with the same dimensions as the original image (use lighter colors for closer objects, darker colors for distant ones). Than, based on rotation, push correct amounts of full displacement (dx, dy displacements for full white color) into shader. The displacement is linear starting on 0, 0 for black color, up to dx, dy for white color. All sources available to download.
Read the rest of this entry »

While some free time today, I have been playing on guiding script, than suddenly I got an idea, I can create some eye-catching thing with it and voilà, here is little thingy, can be used for screensaver etc… Have a nice Friday
Read the rest of this entry »
When embedding MovieClips (with only one frame) from Flash .swf file into your Flex projects, you can fall into runtime issues:
[Embed(source="assets/preloader.swf", symbol="preloader")]
public static const PRELOADER_CLASS:Class;
MovieClip(new Assets.PRELOADER_CLASS());
TypeError: Error #1034: Type Coercion failed: cannot convert *** to flash.display.MovieClip.
Read the rest of this entry »

As previously mentioned, facebook released a new Graph API. It is based on OAuth 2.0 protocol (old authorization token also works). While it is fresh thing, there is no much ActionScript stuff around, so I came with FacebookOAuthGraph class. This class is meant to be used as an abstract class, while it contains just the basic authentication algorithm and call method to request data. It stores access token in SharedObject, so next time you came into app, you get connected on background without noticing (no popup etc.). Your token should expire in 24 hours.
Read the rest of this entry »

When targeting your movie into flash player 9 (or lower), you can fall into issues with text transparency. If TextField contains not embedded font, by default it will not render transparency (alpha) correctly. Luckily, there is a solution for that, as simple as setting blendMode to “layer” parameter to your TextField. This solution was mentioned on Glenn Gervais blog plus there are some other techniques mentioned in comments, for example applying BlurFilter(0, 0) or cacheAsBitmap=true. Thankfully, once you start targeting Flash Player 10, you won’t need any sort of hacks.
Read the rest of this entry »

FlashModPlug is a flash module player created by Ralph Hauwert (UnitZeroOne). It is intended to be a future reference implementation for FlashModPlugLib, intended to be released in the near future. It is an Adobe Alchemy port of the well know LibModPlug, originally created by Olivier Lapicqu and currently maintained by Konstanty Bialkowski. Player includes well known formats such as MOD, XM, IT, S3M, and lesser know formats like Okt and 669.
Read the rest of this entry »
There are multiple libraries that lets you adjust contrast, brightness, hue, saturation. Lets have look at some:
fl.motion.AdjustColor class is a part of Flash CS4:
import flash.filters.ColorMatrixFilter;
import fl.motion.AdjustColor;
// AdjustColor class location:
// Adobe Flash CS4/Common/Configuration/ActionScript 3.0/projects/Flash/src/fl/motion/AdjustColor.as
var color:AdjustColor = new AdjustColor();
color.brightness = brightness;
color.contrast = contrast;
color.hue = 0;
color. saturation = 0;
image.filters = [new ColorMatrixFilter(color.CalculateFinalFlatArray())];
Read the rest of this entry »