« Flash CS5 - Timer » : différence entre les versions
Aller à la navigation
Aller à la recherche
m (Page créée avec « {{Ebauche}} {{Tutoriels Flash|CS5/CS4/CS3|Intermédiaire}} <pageby nominor="false" comments="false"/> == Introduction == Les animations Flash que l'on peut créer avec les... ») |
mAucun résumé des modifications |
||
Ligne 17 : | Ligne 17 : | ||
<source lang="actionscript"> | <source lang="actionscript"> | ||
// Sound | |||
var son = new Salsa(); | |||
// Art | |||
var art2 = new Art(); | |||
art2.x = 150; | |||
art2.y = 200; | |||
/* Countdown Timer | |||
Counts down from a specified number of seconds. | |||
*/ | |||
var COMPTE = 6; | |||
var fl_CountDownTimerInstance:Timer = new Timer(1000,COMPTE); | |||
fl_CountDownTimerInstance.addEventListener(TimerEvent.TIMER, CountDownTimerHandler); | |||
// start the timer | |||
fl_CountDownTimerInstance.start(); | |||
// Manage timer events | |||
function CountDownTimerHandler(event:TimerEvent):void | |||
{ | |||
COMPTE--; | |||
if (COMPTE == 2) // If count down is 2 seconds, then we play sound and add art | |||
{ | |||
addChild(art2); | |||
son.play(); | |||
} | |||
if (COMPTE == 0) // If count down is 0 seconds, then we hide text | |||
{ | |||
text_box.visible=false; | |||
} | |||
} | |||
</source> | </source> |
Version du 26 mai 2011 à 18:12
Cet article est une ébauche à compléter. Une ébauche est une entrée ayant un contenu (très) maigre et qui a donc besoin d'un auteur.
<pageby nominor="false" comments="false"/>
Introduction
Les animations Flash que l'on peut créer avec les outils d'interpolation sont basés sur une logique de cinéma, c-a-d sur la timeline.
Avec ActionScript il est possible d'adopter une logique plus basé sur le temps (time-based)
Exemple d'une simple compte à rebours
// Sound
var son = new Salsa();
// Art
var art2 = new Art();
art2.x = 150;
art2.y = 200;
/* Countdown Timer
Counts down from a specified number of seconds.
*/
var COMPTE = 6;
var fl_CountDownTimerInstance:Timer = new Timer(1000,COMPTE);
fl_CountDownTimerInstance.addEventListener(TimerEvent.TIMER, CountDownTimerHandler);
// start the timer
fl_CountDownTimerInstance.start();
// Manage timer events
function CountDownTimerHandler(event:TimerEvent):void
{
COMPTE--;
if (COMPTE == 2) // If count down is 2 seconds, then we play sound and add art
{
addChild(art2);
son.play();
}
if (COMPTE == 0) // If count down is 0 seconds, then we hide text
{
text_box.visible=false;
}
}