blog

Jozef Chúťka's blog — blog.yoz.sk/page/4/

December 22, 2010

1 Comment

C++ MouseEvent.exe MoveCursor.exe NativeProcess Remotair SystemMouse

SystemMouse Moves And Clicks In Your System

A large mouse pointer in front of a command prompt window.

SystemMouse is a class I managed to create for Remotair demo receiver, in order to show how can remote MouseEvent-s be projected into system. Long story short, you can use moveBy() function to move the system cursor and event() function to make clicks. The class is based on NativeProcess. The NativeProcess class and its capabilities are only available to AIR applications installed with a native installer (extended desktop profile applications) means .exe/.dmg file.

Read the rest of this entry »

December 16, 2010

29 Comments

AIR Androir inputs Remotair sensors transmit

Remotair

Remotair is a concept of transmitting device input events (gestures, accelerometer, camera etc.) into receiving flash or AIR application. Remotair consists of one transmitting application installed on a mobile device or a tablet and one receiving application running on a PC. In order to pair transmitting and receiving application, RTMFP protocol is used. The receiver API is public and released under MIT license.

You can download Remotair application from Android market (link only works on android devices) or see the Android application details on AppBrain. For a receiving application you may use the demo application located on remotair.yoz.sk or you can build your own one using Remotair Receiver API.

Read the rest of this entry »

December 10, 2010

7 Comments

AccelerometerEvent GeolocationEvent GeomagneticField SensorManager

Geolocation + Accelerometer = Orientation

Coordinate axes drawn over two three-dimensional shapes.

In order to get orientation of your android device you need to do “some” math, based on geolocation and accelerometer values. Working with Android native SDK, you are able to get orientation as easy as calling SensorManager.getOrientation(), but when it comes to AIR SDK, you have no access to the native SDK methods. However, thanks to open sources you are able to grab the original source and rewrite the thing into ActionScript. That is exatcly what I have done. The results are GeomagneticField and SensorManager classes. To make this happen you need both AccelerometerEvent and GeolocationEvent values as intput:

Read the rest of this entry »

December 6, 2010

1 Comment

Capabilities DPI SystemScreen

Quick Tip: SystemScreen Class

SystemScreen class is a group of constants helping you to convert between inches, centimeters and pixels based on Capabilities class. The results are not exact, but are pretty close. The following example demonstrates the real device screen size vs. SystemScreen calculated values based on Capabilities.screenDPI:

Real device:    SystemScreen:
       24.0"           30.59"
        3.4"            3.67"

Read the rest of this entry »

November 24, 2010

2 Comments

install navigator run userAgent

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:

it first test user agent if it is an Android device, if so

it asks user to decide wheter to use Android and than

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.

November 23, 2010

No comments

embed SimpleButton swc

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.

November 16, 2010

1 Comment

axis collision FastCollisions Math2D project rectangle

4.000.000 Rectangle Collisions Per Second

Two tilted rectangles with coloured edges and overlapping outlines.

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 »

November 10, 2010

5 Comments

image lanczos LanczosBitmapDataResizer resample resize

Lanczos Resampling With ActionScript

A grid of colour blocks beside a blurred version.

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 »

October 28, 2010

1 Comment

AIR loadPolicyFile Security URLRequest

Quick Tip: AIR 2.5 & Security.loadPolicyFile()

After switching my AIR application into new AIR 2.5 SDK, boom! Every single URLRequest threw an IOErrorEvent. No other exception thrown. So I started digging in in order to find the cause and it appeared to be Security.loadPolicyFile() execution (I am reusing some libs containing these lines) that blocked it all quietly. First I tried to do try-catch block over it, but with no success. Than I just removed the lines for AIR project and voilà, everything back to normal again. URLRequests works again. It seems like AIR does not need loadPolicyFile() for URLRequests at all. Interesting that these loadPolicyFile() were targeting total different domain and were able to break any other requests.

October 25, 2010

5 Comments

BitmapData ByteArray compress imagecolorallocate imagesetpixel unpack

Processing BitmapData.getPixels() With PHP

Have you ever worked with BitmapData.getPixels() method? This method generates a byte array from a rectangular region of pixel data. Writes an unsigned integer (a 32-bit unmultiplied pixel value) for each pixel into the byte array. Thats sounds good, but what is it good for to have a ByteArray full of integers? There is not even a decoder for this format on my backend?!… Well, this format is so cool, and easy to access that you do are able to write your own decoder e.g. in PHP.

The resulting bytes are 32-bit unsigned integers for each pixel represented by AARRGGBB format, followed by another pixels and so on e.g.:

AA RR GG BB:
-- -- -- --
FF FF 00 00
00 00 FF 00

Read the rest of this entry »

« Older Entries

Newer Entries »