Affichage des articles dont le libellé est timer. Afficher tous les articles
Affichage des articles dont le libellé est timer. Afficher tous les articles

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

lundi 31 mai 2010

repeat loop and timer

We learnt something about order and chaos in the last blog.

But we still got a static image. Flash loading the banana's and that was it.

Now we introduce a timer and get the machine alive!

A timer in Flash scripting is a function which can send "events" at a certain time interval. This event is caught by an eventlistener, just like the events from the keyboard and the mouse.


Here is the download, with the example:
http://www.contrechoc.com/flash/orderANDchaos.zip

The timer has to be declared:

var clickTimer:Timer = new Timer(50); //50 is the milliseconds between the ticks
clickTimer.addEventListener("timer", timerHandler2);

and you have to start it ticking:

clickTimer.start();

you can also stop it:


clickTimer.stop();

then like the keyboard or the mouse, you have to prepare a function catching the events:

function timerHandler2 (event:TimerEvent ) {

readSound("click.mp3");}

Now this plays the tick sound every 50 milliseconds, which is a lot!

Try varying the interval....

In the example images are loaded at the tick of the timer.

The images can come in at an unexpected order because the images are loaded from outside. To get a strict order in arrangement from back to front you need to put the images in movieClips, the boxes you already encountered in earlier examples.

mardi 9 mars 2010

FLASH: order and chaos

Order and Chaos this time! Nothing more beautiful for an artist. We work with the Math.random function to get random Numbers. And we work with a double for-loop to get order.

Loading a sequence of images in a for loop.

We learn how to put the timer to good use:
http://www.contrechoc.com/flash/orderANDchaos.zip

We need the timer for taking care of the order of the images which are coming in, being loaded.