Für den Inhalt dieser Seite ist eine neuere Version von Adobe Flash Player erforderlich.

Adobe Flash Player herunterladen


October, 2009


31
Oct 09

Throwing elements naturally with ActionScript 3

This is a demo of the throwableItem Class. Click, drag & throw.
The throwableItem engine only has 175 lines of code!

It it easy to use and it’s for free. Open source for a better world.

Feel free to download it here.


/* IMPORT THROWING ENGINE: */

import com.thirtyOne.prototypes.physics.throwableItem;
var throwEngine:throwableItem;

for (var i:uint=0; i<20; i++) {

	/* CREATE A THROWABLE ITEM: */

	var YOUR_CONTAINER:Sprite = new Sprite();
	var randomScale:Number = Math.random()*1+.5;

	YOUR_CONTAINER.scaleX = randomScale;
	YOUR_CONTAINER.scaleY = randomScale;
	YOUR_CONTAINER.graphics.lineStyle(1, 0xFFFFFF);
	YOUR_CONTAINER.graphics.beginFill(0x000000);
	YOUR_CONTAINER.graphics.drawCircle(0, 0, 75);
	YOUR_CONTAINER.graphics.endFill();

	/* ASSIGN ITEM TO throwableItem CLASS: */

	/* throwEngine.throwableItem(STAGE:Stage, FORCE:Number, DEBUG:Boolean) */
	/* throwEngine.create(CONTAINER:*, X:Number, Y:Number):Sprite */

	throwEngine=new throwableItem(stage,4,false);
	stage.addChild(throwEngine.create(YOUR_CONTAINER, Math.random()*stage.stageWidth,Math.random()*stage.stageHeight));

}

30
Oct 09

Stop coding, start painting.

kame 2009


28
Oct 09

3D Cube Demo

I have been working with papervision since a long time now but even with a simple cube the performance is not even a bit comparable to the native CS4 3D power of Flash itself. Textures doesn’t have do be cached and transformed as Bitmaps, Flash handles MovieClips in 3D like in 2D; vector graphics are still scalable.

This is how to create a simple Cube in CS4:

function createCube():Sprite {

	function createElement(_ausgabe:uint, __x:Number, __y:Number, __z:Number, __rotationX:Number, __rotationY:Number, __rotationZ:Number):void {
		var _container:Sprite = new Sprite;
		_container.x=__x;
		_container.y=__y;
		_container.z=__z;
		_container.rotationX=__rotationX;
		_container.rotationY=__rotationY;
		_container.rotationZ=__rotationZ;
	}

	var _container:Sprite=new Sprite  ;

	//FRONT:
	_cube.addChild(createElement(1, 0, 0, -100, 0, 0, 0));
	//BACK:
	_cube.addChild(createElement(3, 0, 0, 100, 0, 180, 0));
	// RIGHT:
	_cube.addChild(createElement(2, 100, 0, 0, 0, 90+180, 0));
	// LEFT
	_cube.addChild(createElement(4, -100, 0, 0, 0, 90, 0));
	// TOP:
	_cube.addChild(createElement(5, 0, -100, 0, 90+180, 0, 0));
	// BOTTOM:
	_cube.addChild(createElement(6, 0, 100, 0, 90, 0, 0));

	return _container;
}

1 l mate later:

Why not combining the ability to scale without quality-loss with actual Multi-Touch gestures?

Here is the result:


26
Oct 09

Sending MIDI with Flash: MIDI Matrix

Yes I had fun.
You might remember the soundMatrix I coded back in the summer. Version 2 is ready! Touchable & with MIDI support. In the first version I used to trigger WAV samples; version 2 now sends MIDI!

There is a online version with samples available, have fun!

http://www.31media.de/soundMatrix/

For all those who want to know HOW to send MIDI via Flash:
You basically send OSC packets to a XML Socket Server. The FLOSC socket server has a output port that transforms the XML/OSC messages back to MIDI. I use a app called “Occam” for the MIDI transformation.

Update: people were asking where they can find “occam”: Occam was coded 1998 by C. Ramakrishnan at the University of California.
If someone needs Occan, contact me – occam is not online any more.

Update 2: Occam works with Snow Leopard! Nice.
Update 3: Occam is online again! Here is the url: www.illposed.com/software/

Here is the code:

package com.thirtyOne.core{

	import flash.display.*;
	import flash.events.*;
	import org.fwiidom.osc.*;
	import caurina.transitions.Tweener;

	public class MIDIGateway {
		private var oscConn:OSCConnection;
		private static const STR_LOCAL_IP:String="ZION.local";
		private static const STR_REMOTE_IP:String="ZION.local";
		private static const NUM_PORT:Number=6666;

		public function init() {
			//Initialize connection to the FLOSC server
			oscConn=new OSCConnection(STR_LOCAL_IP,NUM_PORT);
			oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT,onConnect);
			oscConn.addEventListener(OSCConnectionEvent.ON_CONNECT_ERROR,onConnectError);
			oscConn.addEventListener(OSCConnectionEvent.ON_CLOSE,onClose);
			oscConn.connect();
		}

		private function onConnect(evtEvent:OSCConnectionEvent):void {
			trace("MIDI MODULE CONNECTED.");
		}

		private function onConnectError(evtEvent:OSCConnectionEvent):void {
			trace("ERROR");
		}

		private function onClose(evtEvent:OSCConnectionEvent):void {
			trace("CONNECTION TO SERVER CLOSED.");
		}

		public function sendMIDI(_note:uint,_velocity:uint):void {
			//Send the actual OSC packet
			///osc/midi/out/noteOnchannel (int)key (int)velocity (int)

			oscConn.sendOSCPacket(new OSCPacket("/osc/midi/out/noteOn",[1,_note+"",_velocity+""],STR_REMOTE_IP,57117));
			Tweener.addTween(new Sprite(), {alpha:1, time:.1, onComplete:function():void
				{
					// KILL MIDI NOTE:
				   oscConn.sendOSCPacket(new OSCPacket("/osc/midi/out/noteOff",[1,_note+"",_velocity+""],STR_REMOTE_IP,57117));
			   }});

		}

	}

}

23
Oct 09

Infinite Loop


23
Oct 09

blobDrop – MultiTouch Version

Here is a video of the blobDrop system:


23
Oct 09

blobDrop 0.7 – merging iPhone and Flash

At the moment I am working on a project called blobDrop.

blobDrop is a realtime photo & video gallery available on iPhone, online or locally on a multitouch device.

blobDrop is a realtime installation. New content is synchronized on every running instance.

Users can participate online by uploading footage or by recording a video. This can also be done locally on a central Multi-Touch device or with an iPhone app.

Take a snapshot – Participate and share impression.

blobDrop iPhone App preview:


13
Oct 09

Multitouch Experiment

Neues Video online!

Multitouch-Installation in Glasplatte.

Beamer ist mit 45 Grad Neigungswinkel an der Wand hinter dem Schreibtisch gemountet.

www.31media.de/?project=multitouchNumbers


9
Oct 09

How to use the iPhone GPS Class CLLocationManager

The following code returns the latitude and longitude of a GPS enabled iPhone:


#import "locationTestAppDelegate.h"
#import 

@implementation locationTestAppDelegate

@synthesize window;
@synthesize locationManager;

- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    [window makeKeyAndVisible];

	locationManager = [[CLLocationManager alloc] init];

}

- (void)dealloc {
    [window release];
    [super dealloc];
}

-(id) init {
	NSLog(@"GPS");
    if (self = [super init]) {
        currentLocation = [[CLLocation alloc] init];
        locationManager = [[CLLocationManager alloc] init];
        locationManager.delegate = self;
        [self start];
    }
    return self;
}

-(void) start {
	NSLog(@"START SEARCHING...");
    [locationManager startUpdatingLocation];
}
-(void) stop {
	NSLog(@"STOP SEARCHING.");
    [locationManager stopUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

	if ( abs([newLocation.timestamp timeIntervalSinceDate: [NSDate date]]) < 120) {
        currentLocation = newLocation;
		NSString *GPSPosition = [NSString stringWithFormat:@"lat=%f&lng=%f", currentLocation.coordinate.latitude, currentLocation.coordinate.longitude ];

		NSLog(@"FOUND YOU: ");
		NSLog(GPSPosition);

		UIAlertView *alert;
		alert = [[UIAlertView alloc] initWithTitle:@"GPS Location:" message:GPSPosition delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
		[alert show];
		[alert release];
	}
}

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
	NSLog(@"locationManager ERROR");
    UIAlertView *alert;
    alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[error description] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
}

@end

8
Oct 09

Flash and Motion Sensors

HAL Update!

There is a new module called “userTracking“. To Track a person in different rooms HAL requires:

  • a X10 USB Device
  • an instance of the Indigo Server running
  • Motion Sensors (Marmitek, X10)

There are two modes:

  • Activity based user tracking
  • Event based user tracking

Activity based user tracking means that locations are being activated when there is motion detected. The location stays active until HAL decides that the location is not needed any more.

Event based user tracking always triggers when a user switches between 2 locations. If you have visitors e.g. HAL can get confused because the user locations are based on tracking ONE person only. If HAL recognizes this the activity based tracking is being activated.

The userTracking Class has a smart mode; HAL recognizes visitors and switches between the normal (room switching based) tracking system and an activity based user tracking.

This is useful when you have the soundTracking modul running.

The catchment area of Computers can easily be extended to control real devices like light, a receiver or even your TV.

With user located programming it is possible to interact with software without even recognizing it. HAL cooperates in an environment, it is part of your daily life; it is like a board computer with a growing artificial intelligence.