Compressing hex string into base64 string

compressLooseWeight

How would you convert / compress 64 character long hex string (0-9a-f) into shortest possible web-safe-char string? (base64 chars is fine) The reverse algorithm must be able to “uncompress” resulting string back into original hex.

I have created p16Top64() compress algorithm and p64Top16() uncompress (reversed) algorithm based on ByteArray class and writeUnsignedInt(), readUnsignedInt() methods. Both p16Top64() and p64Top16() methods are now part of sk.yoz.data.Serialization class. By using p16Top64() method I was able to compress original 64 chars into 44 chars. But, is it possible to compress it into less than 44 char long base64 (0-9a-Z/=) string?

Read the rest of this entry »

Facebook app: “Moje auto budoucnosti”

mojeAutoBudoucnosti

Hurray, another one facbook flash app out and running. Check out the quiz My car of future. Well it is in czech language again… :-)

Update: Facebook application missing session key on first visit

facebookAllowAccess

There are still some issues with facebook flash api vs. facebook communication. Some of them, you as an application developer, will never get into, but general user will. For example, when new user comes into your facebook iframe flash application for a first time, the first thing he see is “Allow Access?” window:

Read the rest of this entry »

Facebook PublishPost with image (update)

facebookPublishPost

Soon, facebook api method PublishUserAction (flash api method) gets deprecated (December 20, 2009). It is suggested to use Facebook.streamPublish instead, and you can find this method in facebook flash api as PublishPost method. If you have problems to make it work take a look at the next simple example that is using image attachment and actionLinkData (as prelink anywhere).

Read the rest of this entry »

Embedding fonts bold vs. black

arialBlack

Embedding fonts into flex app can be a tricky things. Lets suggest you need to embed Arial font in both bold and black style. When you open some desktop application using local font list, you notice Arial font family and under this option there is a list of styles. There is a bold and black style in one list so one would guess it is the same thing setting. Well, it is not. When it comes to embedding into flex, the code varies much more…

Read the rest of this entry »

Binding in flex 3 magic in curly brackets

A lot of things have been said about binding (read basics). But to really understad what is going on behind the scenes lets do some experiments… First to mention is, the curly brackets magic does not work as BindingUtils does. BindingUtils lets you bind only one setter, but curly brackets lets you bind whole logic.

  • test1 – notice constant C1 in (binding constants is valid, and is working without Binding meta tag) and some plus inside expression “Working: {C1 + ‘ ‘ + v2}”
  • test2 – you can use more curly brackets expressions within one attribute “Working: {C1} {v2.toUpperCase()}”
  • test3 – even if you expect function result from your bindable variable it will work “Working: {C1} {uberFunc(v2)}”
  • test4 – notice some math functions here “Working: {v3 + v3}, {Math.pow(v3, 2)}”
  • test5 – simple Object and Array is not working (nor ArrayCollection using brackets) “Not working: {v4.v}, {v5[0]}, {v6[0]}”
  • test6 – getItemAt() on ArrayCollection works just smooth “Working: {v6.getItemAt(0)}”
  • test7 – once you use curly brackets you can not remove binding, but binding can be unbinded when binded by BindingUtils. (both getter and setter in bindProperty must be public!)
  • test8 – binding works when correct event is dispatched “{foo.gimmeSometing()}”
  • test9 – binding with ternary operator is super powerful “{v2 == ‘world’ ? ‘is world’ : ‘not world’}”

Read the rest of this entry »

9 slice scale for bitmaps in flash (no hacks)

9slice_result_flash

9 slice scale is a nice feature, but when you try to use 9 slice in flash ide on MovieClip with bitmap, you will notice a problem. It will just not work as expected. So first thing you try is “Break Apart”, with same result. You are almost there, but due to the solution is not documented you need a small hint: After break apart (ctrl + b), select each of nine slices one by one and group (ctrl + g) individually and voilà its done. See snapshot and result images…

Read the rest of this entry »

ActionScript 3 Performance Testing

Have you ever been curious about performance (benchmark) tests in ActionScript 3? Here are some results gathered from gskinner blog.

Performance testing on loops (read more).

method............................................................. ms
for (var i:uint=0; i<length; i++)                                   40
for (var i:uint=length; i>0; i--)                                   40
var i:uint = 0; while (i < length) i++;                             40
var i:uint = length; while (--i)                                    52
var i:uint = 0; do {} while (++i < length);                         68
var i:uint = length-1; do {} while (i--);                           68
for (var b:* in arr)                                               224
for each (var b:Boolean in arr)                                    216
for each (var b:* in arr)                                          200
for each (var b:* in arr) var c:Boolean = b as Boolean;            686
arr.forEach(arrForEachF)                                          1446

Performance testing on operations with Number, int, uint. (read more)

Assignment (a:TYPE = 0) ......... min - max (ms)
int:                               24 -  45
Number:                            24 -  36
uint:                              25 -  37
Assignment (a:TYPE = 0.5) ....... min - max (ms)
int:                               56 -  83
Number:                            26 -  43
uint:                              57 -  92
Division (a:TYPE = i/2) ......... min - max (ms)
int:                               60 - 105
Number:                            34 -  64
uint:                             184 - 278
Multiplication (a:TYPE = i*2) ... min - max (ms)
int:                               78 - 129
Number:                            39 -  64
uint:                             207 - 280
Addition (a:TYPE = i+2) ......... min - max (ms)
int:                               31 -  49
Number:                            44 -  55
uint:                              85 - 113
Bitshift (a:TYPE = i<<1) ........ min - max (ms)
int:                               31 -  63
Number:                            61 - 114
uint:                              71 - 130

Frame rate optimization

graph-going-up

There has been a lot of articles written about how to optimize your flash / flex application frameRate. In most cases, you only need to have full frameRate when some animation is playing, or tweening etc., in other words when some visual changes are going on. FrameRateOptimizator class does exactly what you need. In default, it uses full frameRate when visual changes and when it stops, optimizator automatically switches to lower frameRate. Optimizator uses bitmapData to compare last state with actual state to catch any visual changes. By default snapshot is executed two times per second in low frameRate (inactive state), or one time per second in full frameRate state (active state), taking approximately not more than 10ms per execution (fast enough).

Read the rest of this entry »

Facebook application type web goes 104 Incorrect signature

When creating flash / flex application for facebook, Application Type “Desktop” will work for you just fine, even when your app is deployed. My app is both embedded via iframe in facebook and standalone application (not in facebook). First I tought desktop mode is just to test my app locally and when finished, I should switch to web type. But guess what, after switching to “Web” type, my standalone application refused some actions (upload photos etc.), resulting in error:

error_code: 104
error_msg: Incorrect signature

So, I switched back to “Desktop” and both iframe and standalone applications works fine. :-) Correct me if I am wrong, but it seems, desktop application type works for facebook flash / flex api in all cases.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes