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

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.

Order and chaos: introducing random

The first lessons were really hard work, getting used to the terminology, all the windows, the scripting language...

This time we study the order of the world and the chaos of art. We will try to find a solution in between.

Start with your own background (big) and have a small image with a transparent background (.png) ready.

Discover the possibility of the so called “for-loop” for making order in the two direction: horizontal and vertical:

in a loop we can repeat things:
see the download: in the first movie we load one banana:
loadImage("banana.png", 100, 100);

in the second movie we load three banana's:
loadImage("banana.png", 100, 100);
loadImage("banana.png", 130, 100);
loadImage("banana.png", 160, 100);

but what about 25? Do we have to type all 25 banana's?

No!

We can do this more effecient:
we use a counter, just a variable counting from 0 to 25!
and we use this counter also to change the coordinates, in this case the x: 30 + counter*40
for (var counter = 0 ; counter < counter ="counter" j =" 1" j =" j" i =" 1" i =" i" style="text-align: center;">



Now we introduce a bit of disorder, using a random function:

for (var j = 1 ; j < j =" j" i =" 1" i =" i" style="text-align: center;">



We used the Math.random() to get a random number between 0 and 1 and have to multiply this to get between say 0 and 25 by 25...

We get this image....


We get a mixture of order and chaos, and we can send the screenshots to Boijmans.

Follow the sequence of order and chaos in these free flash movies, made especially for YOU!

http://www.contrechoc.com/flash/flash-orderAndChaos.zip

try making a function which can read another image, so you can alternate the order of two images! (We did that in class :-))

try varying the scale of the image, to get bigger and smaller images (We did that in class!)

So here are some static results: when you see it happen on screen, or when you repeat the key stroke on your keyboard every time a new unexpected configuration is made by your flash movie.

this is a random grocery shop from Rabia

this is criticizing commercial religions from Nieke

this is font fun from Giulia