mardi 22 juin 2010

webcam plus timer

We made an installation of all the computers in the class room using the webcam activity. A plan was made up by Rabia, Nieke, Giulia and Helena to make an experience of being shot at (when entering the room), using webcam to trigger sounds, then in the middle peacefulness using images which where triggered and get of the screen again, a last row in the back having silhouets (being stalked) leading up to a packman image...

Of course we have put the webcam out of the stage with:
video.x = -3000;

For the triggering and letting disappear the images we needed an extra timer in the webcam activity example:

import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;

var minuteTimer:Timer = new Timer(1000,1);

minuteTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

function onTimerComplete(event:TimerEvent):void
{
winkelWagenMovieClip1.removeChildAt(0);
}
//minuteTimer.stop(); //these last lines to be added in the webcamActivityHandler
// minuteTimer.start();

and here you can find this example Flash CS4:
http://www.contrechoc.com/flash/flash-fun.zip

If you have Flash CS3 just put the textfile of this text in a new flash movie, save in a folder and create in this same folder the folders sounds and the folder images. In these last folders you can put your sonds (.mp3 format) and images. Change the names of these sounds and images in the script...
http://www.contrechoc.com/flash/webcamActivity_CS3script.txt


flash movie and folders structure

mardi 8 juin 2010

Using a webcam

Today we will be fooling around with webcam and microphone.

First of all we can load a webcam on the screen (or stage). This is done in a function.

The webcam can trigger loading of images and playing of sounds etc, so can the microphone.

The structure of the script is not too difficult: you add an object (there is the box again), this object is a webcam for tonight. Then you add an eventlistener. And the eventlisteners triggers a function when the event happens.

So we have:
  • webcam
  • eventlistener
  • function on event
This is the same as:
  • keyboard - eventlistener - function on event
  • mouse - eventlistener - function on event
In the function you can put what you want, it can be loading an image, playing a sound...starting a movie......

The making of the webcam is also a function. This is like the functions of loading an image or streaming a sound. In principle you can copy paste these functions and use them like black boxes.

The working examples can be found here:
http://www.contrechoc.com/flash/flash-fun.zip


Some funny examples from former classes:
http://www.contrechoc.com/flash/DanutasSnorrenShow/webcam.html
Made by Danuta, in her movie your mustache is changed when moving around!

Security setting
Flash is played from website on your computer. So flash movies are not supposed to be able to get data from your computer. Nor are flash movies supposed to activate your webcam without your consent. So every time you use the webcam you have to give permission to do this.

So there is a possibility that when you start the movie with the webcam it wont play immediately.
If nothing is playing or the mic does not respond, first verify if the computer has a mic or webcam, and then try clicking right in the flash window and look at the settings.

More can be done with the webcam than you think: Augmented Reality Flash, or Multitouch Flash is done also with this simple webcam.

Remark: close scrutiny showed that the activity handler is always triggering two times before tting into the normal waiting for a trigger mode. So to do it well,

used:

* webcam activity: eventlistener
* microphone activity: eventlistener

lundi 7 juin 2010

Some keyboard firework

For e-paper we prepared this file:

keyboard Input e-paper prep.zip

in it you find several examples using a bit of turbo scripting:
  1. keyboard input examples + netstreamvideo.fla
  2. keyboard input start stop resume one button video.fla
  3. keyboard input start stop resume one button multiple video.fla
  4. keyboard input image shower.fla
1 is the example movie we saw earlier
2 is the same but start play pause resume in one keystroke, alternating, hitting 1
3 is the same all in one key, but it shows 6 video's played together after hitting 1,2,3,4,5,6
4 shows moving images, coming from a point, this is a bit advanced using a class script for the moving image, but still usable, and fun!

In 4 first try 1 then 2, and .... 3 , ok 4 to stop this avalanche!