Quick Tip: How to run Android application from browser?

For now I succeeded with general approach – Android market application. If you go through Publishing Your Applications you will notice there is a url (with market:// scheme) that can be used to navigate user to your application in Android market. Sadly this url works only from Android device not from desktop (404 not found)! So I came up with this code:

var isAndroid = navigator.userAgent.toLowerCase().search("android") > -1;
if(isAndroid && confirm("Do you want to run onBoard Android application?"))
    window.location = "market://details?id=air.onBoard2Android";

What it does is:

  1. it first test user agent if it is an Android device, if so
  2. it asks user to decide wheter to use Android and than
  3. it redirects user into Android market application showing details of your application

From here user can install or open the application. You may try it on http://onboard.yoz.sk (run from Android device).

I was also playing with the idea about how to run my Android AIR application from browser, well normaly for AIR apps you would use install badge or its customized version in order to check if the application is installed already and then run or install it. But I hit a major problem with air.swf not dispatching Event.INIT on Android flash player :-( … I will surely get back into this to discover more.

Quick Tip: Flash CS Button to Flex

If are trying to embed button symbols (extended SimpleButton) from Flash CS and the results are not what expected:

[Embed(source="assets/elements.swf", symbol="my_button")]
public static const BUTTON_CLASS:Class;
...
addChild(new BUTTON_CLASS())

try exporting your elements into .swc and attach into Flex project, later in code do:

public static const BUTTON_CLASS:Class = my_button;
...
addChild(new BUTTON_CLASS())

This may also help you capturing Event-s dispatched on custom frame from loaded MovieClips.

4.000.000 Rectangle Collisions Per Second

However easy rectangle-collision-detection may look like, it is not. Well, before your rectangles got rotated, all you have to do is to measure points intersection on x and y axis, but once they got rotated you have to rethink the whole algorithm. After reading an article N Tutorial A – Collision Detection and Response, I got inspired and soon Math2D and FastCollisions were born.

What you have to do is to construct a new axis based on rectangle rotation. What first looked like x and y axis, now results into 2 axises per each rectangle (4 in total). First is the one that joins points 1 and 2, second that joins points 2 and 3 (see the final .swf to understand). Once you have 4 new axises you have to project points from other rectangle into the each axis and test intersection.

Read the rest of this entry »

Lanczos Resampling With ActionScript

It has been a while since I worked on some interesting library. But the day has come :-) and here it is. Let me introduce you LanczosBitmapDataResizer class. Lanczos resampling is an interpolation method used to compute new values for sampled data. In resampling (resizing) images it is considered to be one of the best algorithms at all. Lanczos is a convolution filters. That means a filter that for each output value moves the convolution functions point of origin to be centered on the output and then multiplies all the values in the input with the value of the convolution function (kernel) at that location and adds them together.

Read the rest of this entry »

Get Adobe Flash playerPlugin by wpburn.com wordpress themes