Quick tip: always use global position for hitTestPoint()

Just for the record and myself (I should read all the documentation, also the long sentences :-) … Make sure you always check hitTestPoint() against global coordinates of some point.

// we are somewhere deep in myObject.myObject2.myInnerObject
var point:Point;
var someMovingObject:DisplayObject;
var hitShape:DisplayObject;

point = localToGlobal(new Point(someMovingObject.x, someMovingObject.y));
point = someMovingObject.localToGlobal(new Point());
// both give us same results,
// 2nd method is faster in loops while it can use predefined zero point

hitShape.hitTestPoint(point.x, point.y, true);

Even hitShape object is not directly on a stage (but on myInnerObject), you have to use global points for testing hits.

Quick tip: Characters To Include For Czech & Slovak

In a lot of projects we need to embed czech and slovak characters. Here is a list of those I mostly embed:

ÁáÄäČčĎďÉéĚěÍíĺĹľĽŇňÔôÓóŘřŠšŤťÚúŮůÝýŽž !”#$%&’()*+,-./0123456789:;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}<=>'

Quick tip: Timer Listeners Doesn’t Require Remove

Based on profiler (or net.hires.debug.Stats) your Timer listeners doesn’t need to be removed in order to empty garbage collector – the release reference, however it is always a good practice to remove all of them, event those with anonymous functions. Quick proof of concept:

Read the rest of this entry »

Authorizing Iframe Facebook Applications For Graph API

This article continues my exploration of best facebook graph api integration into your flash app. Before continue reading, make sure you understand the previous article. Due to huge interest, I am adding codes that makes your flash app working with graph api within facebook iframe. Try this app live on http://apps.facebook.com/blogoauthgraph/, notice once you get there, you are redirected to grant permissions (if not authorized or granted already) and then redirected back to the app, where you are connected and ready to use graph api.

Read the rest of this entry »

URLRequestBuffer – Buffer Your URLRequests

Let’s suppose your app makes a lot of http requests at once, and you need a good administration for that. Based on used browser your app is running on, you are only allowed to limited request count – mostly its 2 requests per domain, the remaining ones are sitting in browser buffer waiting to finish those actual. URLRequestBuffer is handy class that lets you manage URLRequest-s. E.g. you are creating image gallery and request hundreds of images in gallery at a time, now when user navigates throug the images you need to make some request more prioritized before others, some to be canceled, some may timeout etc. Here comes URLRequestBuffer in scene.

Read the rest of this entry »

Color Picker Not Boring Anymore

For my next project, I needed some lightweight color picker that would be usable but not boring. Nice challenge. So I have created ColorCircle class that may work as a color picker while it dispatches all the necessary ColorCircleEvent-s. I made this class a little dynamic, so you can create custom color pickers on runtime using RGB palette, Black to White fade, solid color or current color with any defined radius (inner + outer) you want.

To create donut shapes I have used shape with lineStyle+drawCircle+cacheAsBitmap drawed over original graphics using BlendMode.ALPHA. To browse RGB pelette there is a paletteColor() method that crawls all color spectrum based on position (0 to 1).

Read the rest of this entry »

Get Adobe Flash player