blog

2010 May Archive at Jozef Chúťka's blog

May 24, 2010

10 Comments

cache etag headers PHP request

Image Caching With PHP

HTTP response headers showing 304 Not Modified.

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 »

May 19, 2010

No comments

benchmark dispatchEvent enumerations event iterations loop

A different view on loops – listener-looping

Two circular arrows crossed by a red X.

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 »

May 13, 2010

1 Comment

Array benchmark linked list loop optimization Vector

Myth Buster – Benchmarking Loops

A bar chart comparing benchmark results.

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 »

May 10, 2010

26 Comments

3d Bitmap displacement pixel bender

Pixel Bender Displacement Map Fakes 3D Effect (update)

A white flower against a blue sky and green field.

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 »

May 7, 2010

1 Comment

abstract drawing Guide Point

Abstract Drawing

An abstract drawing of intersecting red and green lines.

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 »

May 6, 2010

No comments

embed Flash Flex MovieClip Sprite TypeError

Quick tip: Embedded MovieClip not MovieClip?

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 »

May 5, 2010

448 Comments

Access Token Facebook facebook api FacebookOAuthGraph Graph API OAuth

Facebook Graph API & OAuth 2.0 & Flash (update)

Facebook permission dialog requesting access to public information, email, photos and videos.

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 »

May 4, 2010

No comments

alpha BlendMode Layer TextField transparency

Quick tip: Alpha On TextFields

Five lines of sample text with increasing opacity.

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 »

May 4, 2010

2 Comments

8bit alchemy Audio mod SoundObject Synthesizer

8bit Players & Synthesizers In Flash

A FlashModPlug player interface showing track information and volume controls.

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 »

May 4, 2010

1 Comment

AdjustColor brightness color ColorMatrixFilter contrast hue saturation

Quick tip: Contrast & Brightness In ActionScript 3

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 »