Accelerometer, AIR on Android and Tosia

Now it is fun. I did not realize that my handset has the accelerometer sensor until I saw the video. I didn’t even know that AIR for Android supports the thing. So I tried, and it worked! I modified the code from previous posts, removing multitouch events and adding simple AccelerometerEvent. This seems quite straightforward, and the only thing I still do not get is why it is called accelerometer while it aparently measures axis tilt, not acceleration.

Runtime check if the hardware supports us:

			if (Accelerometer.isSupported) 
			{ 
				accl = new Accelerometer(); 
				accl.setRequestedUpdateInterval(200); 
				accl.addEventListener(AccelerometerEvent.UPDATE, handleAccelerometer); 
			} else{
				tf.appendText('\naccelerometer NOT supported');
			}

And the actual handler:

		private function handleAccelerometer(e:AccelerometerEvent):void
		{
			var n:int = sprites.length;
			var s:Handle;
 
			// loop through all alive sprites to update their speed
			for(var i:int = 0; i < n ;  i++){
				s = sprites[i];
				s.speedX -= e.accelerationX * 10;
				s.speedY += e.accelerationY * 10;
			}
		}
 
        // this exits the app on any key (event volume up/down!)
		private function handleKey(e:KeyboardEvent):void
		{
			NativeApplication.nativeApplication.exit();
 
		}

playing AIR on Android

Keeping on with the simplest stuff and having innocent fun with touching a device :)

Portfel Selfcontrol

Walcząc ze stereotypem szewca, co bez butów, napisałem sobie (nam) w AIR aplikację do kontrolowania wydatków. Zapisujemy sobie serie i pojedyncze płatności, korzystając z bazy na serwerze. Mamy siatkę roczną, na której sygnalizowane są zaległości i listę z podsumowaniem. Na liście możemy wyświetlić niemal dowolny podzbiór płatności i obejrzeć go na wykresach.

Fragment siatki rocznej

Płatności miesiącami

Zrzut ekranu z listą i wykresem

Kontrola wydatków przy pomocy Adobe AIR, PHP i MySQL

Next Page »