CHOSSON Sylvain  
Introduction
1. Player ¦ 2. Games ¦ 3. Manager ¦ 4. Developers ¦ 5. Thanks ¦ 6. Contribution ¦ 7. Make a donation
A. Update your computer ¦ B. Set the microphone ¦ C. Links
Télécharger / Download

Handi Computer Games


Cette page est uniquement pour les programmeurs de jeux Adobe Flash, pour qu'ils puissent aisément adapter leurs jeux Flash pour les personnes handicapées.

La page principale du projet Handi Computer Games est disponible ici.


This current page is only for developers, to show them how they could join the project, and adapt their Adobe Flash games for disabled persons.

The main page describing this project of free computer games for disabled persons is available here.

4. Pour les programmeurs Flash

4. For Flash developers

Adaptez vos jeux Flash
pour les personnes handicapées.

Adapt your Flash Games
for disabled persons.

Les jeux simples proposés gratuitement pour HandiComputerGames peuvent ĂŞtre aisĂ©ment paramĂ©trables. The simples games freely available for HandiComputerGames may easily be configured.
Le logiciel HandiComputerGames qui charge les fichiers SWF, charge aussi les fichiers de configuration générés par HandiComputerGamesManager. The application HandiComputerGames loads SWF files, and also the configuration files generated by the application HandiComputerGamesManager.
Le manager conserve toutes les données paramétrables: les liens vers les images, vers les sons, vers les paramètres libres. The manager keeps all the game configurations: links to the image or sound files, values of the various parameters.
Ces paramètres peuvent être récupérés par les jeux flash SWF. Dans le code du fichier Flash enfant, on programmera l'appel de fonctions incluses dans le programme parent de la manière suivante:
You can easily get those parameters from the (child) SWF files. In your source code, you can call the functions as follow :
MovieClip(parent.parent).getImage(4);


TEMPLATE TEMPLATE
Template pour la création de jeu pour Handi Computer Games: Télécharger le fichier FLA

Template for the creation of games for Handi Computer Games: Download the FLA template


Les fonctions suivantes sont actuellement disponibles. D'autres fonctions peuvent être implémentées si vous en avez besoin, contactez-moi:

The following functions are available. Other functions may be implemented on demand.
Obtention des codes utilisés pour les contacteurs
définis dans le gestionnaire (section Menu)
Get the codes used for the switches
defined with the manager (Menu section)
function getSwitch1CODE():int
function getSwitch2CODE():int
function getSwitch3CODE():int
function getSwitch4CODE():int
function getSwitch5CODE():int
NONE: -1
37, 39, 38, 40, 13: "Left arrow" , "Right arrow" , "Up arrow" , "Down arrow" , "ENTER"
32, -5, -4, -3, -2: "SPACE" , "Mouse Click Left" , "Mouse Click Right" , "Mouse Double Click" , "Mouse Click Middle"
8, 16, -6, 9, 48: "Back" , "Shift" , "Shift, Tab" , "Tab" , "0"
49, 50, 51, 52, 53: "1" , "2" , "3" , "4" , "5"
54, 55, 56, 57, 17: "6" , "7" , "8" , "9" , "Ctrl"
33, 34, 35, 36: "PgUP" , "PgDown" , "End" , "Home"
45, 46, 107, 109, 106: "Ins" , "Delete" , "+" , "-" , "*"
111, 110, 65, 66, 67: "/" , "." , "A" , "B" , "C"
68, 69, 70, 71, 72: "D" , "E" , "F" , "G" , "H"
73, 74, 75, 76, 77: "I" , "J" , "K" , "L" , "M"
78, 79, 80, 81, 82: "N" , "O" , "P" , "Q" , "R"
83, 84, 85, 86, 87: "S" , "T" , "U" , "V" , "W"
88, 89, 90, 112, 113: "X" , "Y" , "Z" , "F1" , "F2"
114, 115, 116, 117, 118: "F3" , "F4" , "F5" , "F6" , "F7"
119, 120, 121, 122, 123: "F8" , "F9" , "F10" , "F11" , "F12"
function getTime():String
Cette fonction permet d'obtenir le paramètre au format String défini dans Time (minute). With this function, you can get the defined playing time (in minute) for your game Time (minute).
function setMyTimer(tempsSeconde:int):void
Cette fonction permet de mettre le paramètre de durée de jeu égale au paramètre tempsSeconde.
Il remplace celui définit par HandiComputerGamesManager.exe. Cela permet de forcer la durée du jeu pour qu'il dure plus longtemps, ou le mettre à 0 si vous considerez qu'il est temps de passer au jeu suivant.
With this function, you can set (in second) the playing time for your game (overriding the one defined with HandiComputerGamesManager.exe).
You can then force the game to be longer or even, when you want, decide that's the current game is over then, it's time to play the next game then you can force the playing time to be zero.
function getLevel(position:int):String
Les string retournés sont:
  VeryEasy  Easy  Normal  Difficult  VeryDifficult
Return string:
  VeryEasy  Easy  Normal  Difficult  VeryDifficult
function getTechnoTouchScreen():String
Cette fonction permet d'obtenir le paramètre au format String ("true" and "false") défini dans Touch Screen (=écran tactile) You can get the String ("true" and "false") defined by Touch Screen
function getTechnoSwitch():String
Cette fonction permet d'obtenir le paramètre au format String ("true" and "false") défini dans Switches (=contacteur) You can get the String ("true" and "false") defined by Switches
function getTechnoMic():String
Cette fonction permet d'obtenir le paramètre au format String ("true" and "false") défini dans Microphone You can get the String ("true" and "false") defined by Microphone
function getColorBackR():String
Cette fonction permet d'obtenir le paramètre au format String défini dans Background color: R Get the String defined by Background color: R
function getColorBackG():String
Cette fonction permet d'obtenir le paramètre au format String défini dans Background color: G Get the String defined by Background color: G
function getColorBackB():String
Cette fonction permet d'obtenir le paramètre au format String défini dans Background color: B Get the String defined by Background color: B
function getPlaySound():string
Cette fonction permet d'obtenir le paramètre Play Sounds du jeu en cours pour savoir si les sons du jeu doivent être joués, ou si un ajustement du volume sonore doit être fait. Get the String defined by Play Sounds to know if the sounds have to be played, or if the sound level has to be adjusted.
Les string retournés sont: "0", "0.1", "0.2" à "1"
The returned string are: "0", "0.1", "0.2" Ă  "1"
  var soundChan:SoundChannel;
  var soundVolume:Number =0.4;
  if (MovieClip(parent.parent)!=null) {
     soundVolume = MovieClip(parent.parent).getPlaySound();
  }
  var mySound:Sound = new Sound();
  requeteSound.url = soundPath;
  mySound.load(requeteSound);
  mySound.addEventListener( IOErrorEvent.IO_ERROR , SonErreur );
  var trans:SoundTransform = new SoundTransform(soundVolume, 0);
  soundChan = mySound.play(0, 0, trans);
function getSoundIntro():String
Cette fonction permet d'obtenir le paramètre au format String défini dans Intro Son. Get the String defined by Intro Son.
function getImageBackground():String
Cette fonction permet d'obtenir le paramètre au format String défini dans Background image. Get the String defined by Background image.
function getImage(position:int):String
Cette fonction permet d'obtenir les paramètres au format String définis dans Image 1 à Image 9. La variable position:int étant le numéro de l'image. Get the String defined by Image 1 to Image 9. The variable position:int is the number of the image.
function getSound(position:int):String
Cette fonction permet d'obtenir les paramètres au format String définis dans Sound 1 à Sound 9. La variable position:int étant le numéro du son. Get the String defined by Sound 1 to Sound 9. The variable position:int is the number of the sound.
function getParam(position:int):String
Cette fonction permet d'obtenir les paramètres au format String définis dans Param 1 à Param 40. La variable position:int étant le numéro du paramètre. Get the String defined by Param 1 to Param 40. The variable position:int is the number of the parameter.
function traceAdvice(whatYouWantToDisplay:String)
Cette fonction permet d'afficher dans la partie Advice le texte whatYouWantToDisplay. Celui ci permet par exemple d'afficher un conseil si une image, un son ou l'un des paramètre n'est pas correctement défini avec le gestionnaire HCGManager.exe ou s'il n'existe pas. This function enables you to display in the section Advice the text whatYouWantToDisplay. You can the display an advice if for example images or sounds are not found or one of the parameter is ill-defined with HCGManager.exe or does not exist.
function traceDescription(whatYouWantToDisplay:String)
Cette fonction permet d'afficher dans la partie Description le texte whatYouWantToDisplay. This function enables you to display in the section Description the texte whatYouWantToDisplay.
function setFrameRate(ImagePerSecond:Number)
Permet de définir la fréquence des images du chargeur de jeu (nombre d'images par seconde). Set the frame rate of the loader (images per second)
IMPORTANT:
Vous devez ajouter dans le SWF enfant une fonction qui coupe les sons, arrĂŞte les timers, fait le grand nettoyage qui n'est pas fait avec la seule fonction unload.
IMPORTANT:
You have to add in your code a function that stops everything like the sounds and timers when the SWF is unloaded by the parent application HandiComputerGames.exe ... Clean everything !
loaderInfo.addEventListener( Event.UNLOAD , cleanAll );
// Function called when the SWF is unloaded in the HCG.exe

function cleanAll(pEvt:Event):void {
     // Your code here, for example:
     myTimer.stop();
     mySound.stop();
     loaderInfo.removeEventListener( Event.UNLOAD , cleanAll);
}
TEMPLATE TEMPLATE
Template pour la création de jeu pour Handi Computer Games: Télécharger le fichier FLA

Template for the creation of games for Handi Computer Games: Download the FLA template

////////////////////////////////////////////////////////////////////////
//
// Template for the creation of flash games for HandiComputerGames
//
// version 2.0 // Last update: 21 June 2009
// Actionscript AS3
//
// Three devices may be used :
// 1) a microphone : when the sound level is higher than a threshold an action is done
// 2) switches : up to five switches returning 5 keycodes may be used (but keep in mind sometime just one switch can be used, you have to show for example a focus on the objects moving according to a timer)
// 3) touch screen (the same use as mouse with the same event Mouse_Down, mouse_over, click ...)
//
// In this template here are the parameters to use:
// Image1 to Image9 : links to the first nine images
// Sound1 to Sound9 : links to the first nine sounds associated with the previous nine images
// arrayParams[1] to param6 : usualy left to set for example the speed of the images or the way they are moving when clicked
// param7 and param8 : 10th image and sound
// param2i+1 and param2i+2 : (9+((2i+1)-1)/2-2)th image and sound
//
// Actions :
// 1) For each switch an image is sequentialy chosen and place on top of the images and the associated sound is played
// If there is only one switch, the images are rotating
// If not
// switch1 : the image is moving up
// switch2 : the image is moving down
// switch3 : the image is moving left
// switch4 : the image is moving right
// switch5 : the image is moving randomly
//
// 2) Clicked:
// The clicked image is placed on top, the sound is played and the image is moving randomly on the stage
//
// 3) Microphone :
// The image is placed on top, the sound is played and the image is moving randomly on the stage
//
// Several functions available to get or set parameters from or for the parent application, among them:
// MovieClip(parent.parent).getTime();
// MovieClip(parent.parent).setMyTimer(tempsSeconde:int);
// MovieClip(parent.parent).getLevel();
// MovieClip(parent.parent).getTechnoTouchScreen();
// MovieClip(parent.parent).getTechnoSwitch():;
// MovieClip(parent.parent).getTechnoMic();
// MovieClip(parent.parent).getPlaySound();
// MovieClip(parent.parent).getImageBackground();
// MovieClip(parent.parent).getImage(position:int);
// MovieClip(parent.parent).getSound(position:int);
// MovieClip(parent.parent).getParam(position:int);
// MovieClip(parent.parent).traceAdvice(whatYouWantToDisplay:String);
// MovieClip(parent.parent).setFrameRate(ImagePerSecond:Number);
// MovieClip(parent.parent).getSwitch1CODE();
// MovieClip(parent.parent).getSwitch2CODE();
// MovieClip(parent.parent).getSwitch3CODE();
// MovieClip(parent.parent).getSwitch4CODE();
// MovieClip(parent.parent).getSwitch5CODE();
//
// If you need more parameters from the parent application, let me know !
//
// website: http://sylvain.chosson.free.fr/handicomputergames.php
//
////////////////////////////////////////////////////////////////////////

import flash.display.Sprite;
import flash.media.Microphone;
import flash.system.Security;
import flash.system.SecurityPanel;
import flash.display.*;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.events.MouseEvent;
import fl.motion.easing.*;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.geom.*;
import flash.display.BitmapData;
import flash.events.*;
import flash.events.IOErrorEvent;

////////////////////////////////////////////////////////////////////////
// Variables
////////////////////////////////////////////////////////////////////////
var backgroundContainer:Sprite = new Sprite();
addChild(backgroundContainer);
var mainContainer:Sprite = new Sprite();
addChild(mainContainer);

var containerLoader:Sprite;

var soundVolume:Number = 0.6;
var PosXInit:Number, PosYInit:Number;
var PosX:Number, PosY:Number;
var posX:Number, posY:Number;
var tempX:Number, tempY:Number;
var randomScaleX:Number, randomScaleY:Number;
var randomTimeScaleX:Number, randomTimeScaleY:Number;
var randomPosX:Number, randomPosY:Number;
var randomTimePosX:Number, randomTimePosY:Number;
var varX:Number;
var offsetX:Number, offsetY:Number;
var varduration:Number;
var ImageSize:Number = 5;
var NumberOfSwitches:Number = 0;
var ClicNumber:int = 1;
var nbrImagesDisplayed:int = 0;
var intNum:Number = -1;

var trans:SoundTransform = new SoundTransform(soundVolume, 0);
var mainSoundChan:SoundChannel = new SoundChannel();

var requestImage:URLRequest = new URLRequest();
var requestSound:URLRequest = new URLRequest();

var arrayImages:Array = new Array(9);
var arraySoundsPath:Array = new Array(9);
var arrayParams:Array = new Array(101);
var arrayImagesAllNumber:Number = 0;
var arrayImagesAll:Array = new Array(110);
var arraySounds:Array = new Array(110);
var ImageBackground:String = "empty";

var Switch1CODE:Number = -1;
var Switch2CODE:Number = -1;
var Switch3CODE:Number = -1;
var Switch4CODE:Number = -1;
var Switch5CODE:Number = -1;

var MENUKeyboardName= new Array("NONE",
"Left arrow","Right arrow","Up arrow","Down arrow","ENTER","SPACE","Mouse Click Left","Mouse Click Right","Mouse Double Click","Mouse Click Middle",
"Backspace","Shift","Shift, Tab","Tab","0","1","2","3","4","5",
"6","7","8","9","Ctrl","PgUP","PgDown","End","Home",
"Ins","Delete","+","-","*","/",".","A","B","C",
"D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T","U","V","W",
"X","Y","Z","F1","F2","F3","F4","F5","F6","F7",
"F8","F9","F10","F11","F12");
var MENUKeyboardCode= new Array(-1,
37,39,38,40,13, // "Left arrow","Right arrow","Up arrow","Down arrow","ENTER",
32,-5,-4,-3,-2, // "SPACE","Mouse Click Left","Mouse Click Right","Mouse Double Click","Mouse Click Middle",
8,16,-6,9,48, // "Backspace","Shift","Shift, Tab","Tab","0",
49,50,51,52,53, // "1","2","3","4","5",
54,55,56,57,17, // "6","7","8","9","Ctrl",
33,34,35,36, // "PgUP","PgDown","End","Home",
45,46,107,109,106, // "Ins","Delete",PAVE NUMERIQUE "+","-","*",
111,110,65,66,67, //"/",".","A","B","C",
68,69,70,71,72, //"D","E","F","G","H",
73,74,75,76,77, //"I","J","K","L","M",
78,79,80,81,82, // "N","O","P","Q","R",
83,84,85,86,87, // "S","T","U","V","W",
88,89,90,112,113, // "X","Y","Z","F1","F2",
114,115,116,117,118, // "F3","F4","F5","F6","F7",
119,120,121,122,123);// "F8","F9","F10","F11","F12"

//////////////////////////////////////////////////////////////////////////////////////////////
// Initialisation of the arrays
//////////////////////////////////////////////////////////////////////////////////////////////
var itab:int = 0;
for (itab = 0; itab < arrayParams.length; itab++) {
arrayParams[itab] = "empty";
}
for (itab = 0; itab < arrayImages.length; itab++) {
arrayImages[itab] = "empty";
}
for (itab = 0; itab < arraySoundsPath.length; itab++) {
arraySoundsPath[itab] = "empty";
}
for (itab = 0; itab < arraySounds.length; itab++) {
arraySounds[itab] = "empty";
}
for (itab = 0; itab < arrayImagesAll.length; itab++) {
arrayImagesAll[itab] = "empty";
}

//////////////////////////////////////////////////////////////////////////////////////////////
/// UNLOAD from HandiComputerGames.exe
//////////////////////////////////////////////////////////////////////////////////////////////
loaderInfo.addEventListener( Event.UNLOAD , desactivation );
function desactivation(pEvt:Event):void {
try {
mainSoundChan.stop();
mic.removeEventListener(ActivityEvent.ACTIVITY, activityHandler);
mic.removeEventListener(StatusEvent.STATUS, statusHandler);
removeEventListener(Event.ENTER_FRAME, testmicro);
stage.removeEventListener(MouseEvent.MOUSE_DOWN,addImageStatic);
loaderInfo.removeEventListener( Event.UNLOAD , desactivation );
stage.removeEventListener(KeyboardEvent.KEY_DOWN, listenKeyBoard);
} catch (Error) {}
}

//////////////////////////////////////////////////////////////////////////////////////////////
// INITIALISATION
//////////////////////////////////////////////////////////////////////////////////////////////
function init():void {

mainContainer.visible = false;

// FOR TESTING: the file are in the associated zip file or installed with the HandiComputerGamesSetup
arrayImages[1] = "01_Images/Lettres/A.gif"; arrayImages[2] = "01_Images/Lettres/B.gif";
arrayImages[3] = "01_Images/Lettres/C.gif"; arrayImages[4] = "01_Images/Lettres/D.gif";
arrayImages[5] = "01_Images/Lettres/E.gif"; arrayImages[6] = "01_Images/Lettres/F.gif";
arrayImages[7] = "01_Images/Lettres/G.gif"; arrayImages[8] = "01_Images/Lettres/H.gif";
arrayImages[9] = "01_Images/Lettres/I.gif";
arraySoundsPath[1] = "01_Sons/Letters/FR/A.mp3"; arraySoundsPath[2] = "01_Sons/Letters/FR/B.mp3";
arraySoundsPath[3] = "01_Sons/Letters/FR/C.mp3"; arraySoundsPath[4] = "01_Sons/Letters/FR/D.mp3";
arraySoundsPath[5] = "01_Sons/Letters/FR/E.mp3"; arraySoundsPath[6] = "01_Sons/Letters/FR/F.mp3";
arraySoundsPath[7] = "01_Sons/Letters/FR/G.mp3"; arraySoundsPath[8] = "01_Sons/Letters/FR/H.mp3";
arraySoundsPath[9] = "01_Sons/Letters/FR/I.mp3";
arrayParams[2] = "1";
arrayParams[7] = "01_Images/Lettres/J.gif"; arrayParams[8] = "01_Sons/Letters/FR/J.mp3";
arrayParams[9] = "01_Images/Lettres/L.gif"; arrayParams[10] = "01_Sons/Letters/FR/L.mp3";
arrayParams[11] = "01_Images/Lettres/N.gif"; arrayParams[12] = "01_Sons/Letters/FR/N.mp3";
arrayParams[13] = "01_Images/Lettres/P.gif"; arrayParams[14] = "01_Sons/Letters/FR/P.mp3";
arrayParams[15] = "01_Images/Lettres/R.gif"; arrayParams[16] = "01_Sons/Letters/FR/R.mp3";
ImageBackground = "01_Images/Background/MCCC/MCCC_SeaBeach2.JPG";
Switch1CODE = 37; Switch2CODE = 39; Switch3CODE = 38; Switch4CODE = 40; Switch5CODE = 32;
// << FOR TESTING

// Get all the parameters defined with HandiComputerGamesManager.exe
if (MovieClip(parent.parent)!=null) {

soundVolume = MovieClip(parent.parent).getPlaySound();
trans = new SoundTransform(soundVolume, 0);

ImageBackground = MovieClip(parent.parent).getImageBackground();

for (itab = 1; itab < arrayParams.length; itab++) {
arrayParams[itab] = MovieClip(parent.parent).getParam(itab);
}
for (itab = 1; itab < arrayImages.length; itab++) {
arrayImages[itab] = MovieClip(parent.parent).getImage(itab);
}
for (itab = 1; itab < arraySoundsPath.length; itab++) {
arraySoundsPath[itab] = MovieClip(parent.parent).getSound(itab);
}
Switch1CODE = MovieClip(parent.parent).getSwitch1CODE();
Switch2CODE = MovieClip(parent.parent).getSwitch2CODE();
Switch3CODE = MovieClip(parent.parent).getSwitch3CODE();
Switch4CODE = MovieClip(parent.parent).getSwitch4CODE();
Switch5CODE = MovieClip(parent.parent).getSwitch5CODE();
// Some parameters for the switches may be mouse events, this template do not take it into account for the moment.
//"Mouse Click Left" , "Mouse Click Right" , "Mouse Double Click" , "Mouse Click Middle"
// -5 -4 -3 -2
if (Switch1CODE == -2 || Switch1CODE == -3 || Switch1CODE == -4 || Switch1CODE == -5 || Switch2CODE == -2 || Switch2CODE == -3 || Switch2CODE == -4 || Switch2CODE == -5 ||
Switch3CODE == -2 || Switch3CODE == -3 || Switch3CODE == -4 || Switch3CODE == -5 || Switch4CODE == -2 || Switch4CODE == -3 || Switch4CODE == -4 || Switch4CODE == -5 ||
Switch5CODE == -2 || Switch5CODE == -3 || Switch5CODE == -4 || Switch5CODE == -5 ) {
MovieClip(parent.parent).traceAdvice(" The codes of the switches are mouse events, this template do not take it into account for the moment.");
}
// In this template I use the difficulty level defined by HandiComputerManager to set the image size
switch (MovieClip(parent.parent).getLevel()) {
case "VeryEasy" :
ImageSize = 3;
break;
case "Easy" :
ImageSize = 4;
break;
case "Difficult" :
ImageSize = 6;
break;
case "VeryDifficult" :
ImageSize = 7;
break;
default :
ImageSize = 5;
break;
}
}// << Get all the parameters defined with HandiComputerGamesManager.exe

if (Switch1CODE!=-1) {
NumberOfSwitches=1;
if (Switch2CODE!=-1) {
NumberOfSwitches=2;
if (Switch3CODE!=-1) {
NumberOfSwitches=3;
if (Switch4CODE!=-1) {
NumberOfSwitches=4;
if (Switch5CODE!=-1) {
NumberOfSwitches=5;
} } } } }


var i:int;
for (i = 1; i< arrayImages.length; i++) {
try {
if (arrayImages[i]!="empty") {
addImageInArray(i);
}
} catch (Error) {}
}

// In this template, the first 6 parameters are to define the way the images are moving
// Param7 to param100 are for Images and Sounds
// We start at i = 7 because the first 6 params are for the parameters
// We use i = i + 2 because we alternate in this exemple Image and sounds
for (i = 7; i <arrayParams.length; i = i + 2) {
try {
if (arrayParams[i]!="empty") {
addImageParamInArray(i);
}
} catch (Error) {}
}

// Add the images on the stage

for (i = 1; i< arrayImagesAll.length; i++) {
try {
if (arrayImagesAll[i]!="empty") {
addImage(i);
}
} catch (Error) {}
}

if (ImageBackground != "empty") {
try {
var loaderImage:Loader = new Loader();
loaderImage.name = "Background";
requestImage.url = ImageBackground;
loaderImage.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR , imageError );
try {
loaderImage.load(requestImage);
}
catch(IOError){}
loaderImage.contentLoaderInfo.addEventListener( Event.COMPLETE, finishBackground );
backgroundContainer.addChild(loaderImage);
} catch (e:Error) {}
}

if ( arrayParams[1]=="empty" || arrayParams[1]=="0" || arrayParams[6] =="1" ) {
stage.addEventListener(MouseEvent.MOUSE_DOWN,addImageStatic,false);
}

mainContainer.visible = true;
}

//////////////////////////////////////////////////////////////////////////////////////////////
// DEFINE THE MICROPHONE ACCESS and ACTIONS
//////////////////////////////////////////////////////////////////////////////////////////////
var mic:Microphone = Microphone.getMicrophone();
mic.setLoopBack(true);
// Security.showSettings(SecurityPanel.MICROPHONE);
if (mic != null) {
mic.setUseEchoSuppression(true);
mic.setSilenceLevel(50);
mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
mic.addEventListener(StatusEvent.STATUS, statusHandler);
mic.soundTransform = new SoundTransform(0, 0);
}
function activityHandler(event:ActivityEvent):void {}
function statusHandler(event:StatusEvent):void {}
addEventListener(Event.ENTER_FRAME, testmicro);

function testmicro(event:Event):void {

// If the sound level is higher than 50, let's do something
if (mic.activityLevel> 50 ) {

intNum = intNum+1;
// intNum is incremented each time a Key is touched or the mic level is reached
if ( intNum > mainContainer.numChildren-1 || mainContainer.numChildren == 0) {
intNum = 0;
}

var intNumString:String = (intNum+1).toString();
try {
if (arraySounds[int(mainContainer.getChildByName(intNumString).name)%arrayImagesAllNumber]!="empty") {
mainSoundChan = arraySounds[int(mainContainer.getChildByName(intNumString).name)%arrayImagesAllNumber].play(0, 0, trans);
}
} catch (e:Error) {}
// Place the clicked object on top
try{
mainContainer.setChildIndex((mainContainer.getChildByName(intNumString) as Sprite), mainContainer.numChildren-1);
} catch(Error){}
try {
PosXInit = mainContainer.getChildByName(intNumString) .x;
PosYInit = mainContainer.getChildByName(intNumString) .y;
PosX = Math.random()*700+50;
PosY = Math.random()*500+50;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenX.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenX = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"x", Regular.easeOut, PosXInit , PosX, varduration, true );
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"y", Regular.easeOut, PosYInit , PosY, varduration, true );
} catch (Error) {}
}
}

//////////////////////////////////////////////////////////////////////////////////////////////
// SWITCHES action
//////////////////////////////////////////////////////////////////////////////////////////////
stage.addEventListener(KeyboardEvent.KEY_DOWN, listenKeyBoard);
// Some parameters for the switches may be mouse events, this template do not take it into account for the moment.
//"Mouse Click Left" , "Mouse Click Right" , "Mouse Double Click" , "Mouse Click Middle"
// -5 -4 -3 -2
function listenKeyBoard(pEvt:KeyboardEvent):void {

// intNum is incremented each time a Key is touched or the mic level is reached
intNum = intNum+1;
// intNum is incremented each time a Key is touched or the mic level is reached
if ( intNum > mainContainer.numChildren-1 || mainContainer.numChildren == 0) {
intNum = 0;
}

var intNumString:String = (intNum+1).toString();

// Read the corresponding sound
if (int((mainContainer.getChildByName(intNumString) as Sprite).name)%(arrayImagesAllNumber)!= 0)
{
if (arraySounds[int((mainContainer.getChildByName(intNumString) as Sprite).name)%(arrayImagesAllNumber)]!="empty") {
try { mainSoundChan = arraySounds[int((mainContainer.getChildByName(intNumString) as Sprite).name)%(arrayImagesAllNumber)].play(0, 0, trans);
} catch (e:Error) {}
}
}
else
{
try { mainSoundChan = arraySounds[arrayImagesAllNumber].play(0, 0, trans);
} catch (e:Error) {}
}

try {
// Place the clicked object on top
mainContainer.setChildIndex((mainContainer.getChildByName(intNumString) as Sprite), mainContainer.numChildren-1);

switch (NumberOfSwitches)
{
case 1: // If there is 1 switch, the images are rotating
PosYInit = mainContainer.getChildByName(intNumString).y;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenXinterception.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenXinterception = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"rotation", Regular.easeOut, 0 , 360, varduration, true );
break;
case 2: // If there are 2 switches
case 3: // If there are 3 switches
case 4: // If there are 4 switches
case 5: // If there are 5 switches
switch (pEvt.keyCode) {
case Switch1CODE :// Image goes UP
PosYInit = mainContainer.getChildByName(intNumString).y;
PosY = Math.random()*(PosYInit-50)+25;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"y", Regular.easeOut, PosYInit , PosY, varduration, true );
break;

case Switch2CODE :// Image goes DOWN
PosYInit = mainContainer.getChildByName(intNumString).y;
PosY = Math.random()*(600-PosYInit-50)+25;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"y", Regular.easeOut, PosYInit , PosYInit+PosY, varduration, true );
break;

case Switch3CODE :// Image goes LEFT
PosXInit = mainContainer.getChildByName(intNumString).x;
PosX = Math.random()*(PosXInit-50)+25;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"x", Regular.easeOut, PosXInit , PosX, varduration, true );
break;

case Switch4CODE :// Image goes RIGHT
PosXInit = mainContainer.getChildByName(intNumString).x;
PosX = Math.random()*(800-PosXInit-50)+25;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"x", Regular.easeOut, PosXInit , PosXInit+PosX, varduration, true );
break;

case Switch5CODE :// Image goes RANDOM
PosXInit = mainContainer.getChildByName(intNumString).x;
PosYInit = mainContainer.getChildByName(intNumString).y;
PosX = Math.random()*700+50;
PosY = Math.random()*500+50;
varduration = Math.random()*3+1;
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenX.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenX = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"x", Regular.easeOut, PosXInit , PosX, varduration, true );
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY.stop();
((mainContainer.getChildByName(intNumString) as Sprite).getChildAt(0) as LoaderTween).tweenY = new Tween(mainContainer.getChildByName(intNumString) as Sprite,"y", Regular.easeOut, PosYInit , PosY, varduration, true );
break;

default :
break;
}
break
}
} catch (Error) {}
}

//////////////////////////////////////////////////////////////////////////////////////////////
/// Function Click image // TOUCH SCREEN - MOUSE
//////////////////////////////////////////////////////////////////////////////////////////////
function clicImages(pEvt:MouseEvent):void {

// If an image is clicked, we stop the event propagation to avoid to add a static image where we just clicked
pEvt.stopPropagation();

//trace("clicImages "+int(pEvt.currentTarget.getChildAt(0).name)+" "+(mainContainer.numChildren-1));
//trace("clicImages "+mainContainer.getChildByName(pEvt.currentTarget.getChildAt(0).name));

// pEvt.currentTarget : Sprite
// pEvt.currentTarget.getChildAt(0) : LoaderTween
trans = new SoundTransform(soundVolume, 0);

// Place the clicked object on top
mainContainer.setChildIndex(mainContainer.getChildByName(pEvt.currentTarget.getChildAt(0).name), mainContainer.numChildren-1);

// Read the corresponding sound
if (int(pEvt.currentTarget.getChildAt(0).name)%(arrayImagesAllNumber)!= 0)
{
if (arraySounds[int(pEvt.currentTarget.getChildAt(0).name)%(arrayImagesAllNumber)]!="empty") {
try { mainSoundChan = arraySounds[int(pEvt.currentTarget.getChildAt(0).name)%(arrayImagesAllNumber)].play(0, 0, trans);
} catch (e:Error) {}
}
}
else
{
try { mainSoundChan = arraySounds[arrayImagesAllNumber].play(0, 0, trans);
} catch (e:Error) {}
}

pEvt.currentTarget.getChildAt(0).tweenX.stop();
pEvt.currentTarget.getChildAt(0).tweenY.stop();

tweenFunction(pEvt);
}

//////////////////////////////////////////////////////////////////////////////////////////////
/// Function add image
//////////////////////////////////////////////////////////////////////////////////////////////
function addImage(position:int):void {
var LoaderTweenImage:LoaderTween = new LoaderTween();
containerLoader = new Sprite();
// Initialisation of the tweens (to avoid errors when we stop the tweens)
LoaderTweenImage.tweenX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenY = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleY= new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenXX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenYY = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleXX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleYY= new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenXinterception = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenYinterception = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );

LoaderTweenImage.chargeur.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR , imageError );
LoaderTweenImage.chargeur.contentLoaderInfo.addEventListener( Event.COMPLETE, finishImage );

containerLoader.name = LoaderTweenImage.name = LoaderTweenImage.chargeur.name = position.toString();
containerLoader.addEventListener( MouseEvent.MOUSE_DOWN, clicImages, true );
containerLoader.addChild(LoaderTweenImage);

if (arrayImagesAll[ position % arrayImagesAll.length ]!="empty") {
try{
requestImage.url = arrayImagesAll[position % arrayImagesAll.length];
try {
LoaderTweenImage.chargeur.load(requestImage);
}
catch(IOError){}
}
catch(e:Error){}
}
if (arraySoundsPath[position % arraySoundsPath.length]!="empty") {
var monSon:Sound = new Sound();
monSon.addEventListener( IOErrorEvent.IO_ERROR , SoundError );
try {
requestSound.url = arraySoundsPath[position % arraySoundsPath.length];
try {
monSon.load(requestSound);
}
catch(IOError){}
} catch (e:Error) {}
}
containerLoader.buttonMode = true;
LoaderTweenImage.chargeur.scaleX = LoaderTweenImage.chargeur.scaleY = 1;

if (int(arrayParams[1]) == 1 ) {
// Place the images below the previous images
mainContainer.addChildAt(containerLoader,0);
} else {
// Place the images on top of the previous images
mainContainer.addChild(containerLoader);
}

offsetX = 200;
offsetY = 150;
// Param1 : define the interception movement
switch (arrayParams[1]) {
case "1":
varX = Math.random()*100+offsetX;
LoaderTweenImage.tweenXinterception = new Tween(containerLoader, "x", None.easeNone, -varX, 800+varX, Math.random()*3+1, true);//*param8Num+param7Num
LoaderTweenImage.tweenXinterception.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
containerLoader.y = Math.random()*500+50;
break;
default: // No interception
containerLoader.x = Math.random()*700+50;
containerLoader.y = Math.random()*500+50;
break;
}
// Param2 : Image still or slightly moving
switch (arrayParams[2]) {

case "0" :
break;

case "empty" :
tempX = LoaderTweenImage.chargeur.scaleX;
tempY = LoaderTweenImage.chargeur.scaleY;
LoaderTweenImage.tweenScaleXX = new Tween(LoaderTweenImage.chargeur, "scaleX", Regular.easeOut,tempX ,tempX+Math.random()*0.1, Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleYY = new Tween(LoaderTweenImage.chargeur, "scaleY", Regular.easeOut,tempY ,tempY+Math.random()*0.1, Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenScaleYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
posX = LoaderTweenImage.chargeur.x;
posY = LoaderTweenImage.chargeur.y;
LoaderTweenImage.tweenXX = new Tween(LoaderTweenImage.chargeur, "x", Regular.easeOut,posX ,posX+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenYY = new Tween(LoaderTweenImage.chargeur, "y", Regular.easeOut,posY ,posY+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
break;

default :
// the difference with the "empty" case is that I use the param2 also to set the variation of the size (param2 could be 100)
tempX = LoaderTweenImage.chargeur.scaleX;
tempY = LoaderTweenImage.chargeur.scaleY;
LoaderTweenImage.tweenScaleXX = new Tween(LoaderTweenImage.chargeur, "scaleX", Regular.easeOut,tempX ,tempX+Math.random()*0.1*int(arrayParams[2]), Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleYY = new Tween(LoaderTweenImage.chargeur, "scaleY", Regular.easeOut,tempY ,tempY+Math.random()*0.1*int(arrayParams[2]), Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenScaleYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
posX = LoaderTweenImage.chargeur.x;
posY = LoaderTweenImage.chargeur.y;
LoaderTweenImage.tweenXX = new Tween(LoaderTweenImage.chargeur, "x", Regular.easeOut,posX ,posX+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenYY = new Tween(LoaderTweenImage.chargeur, "y", Regular.easeOut,posY ,posY+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
break;
}
}

function addImageInArray(position:int):void {

if (arrayImages[ position % arrayImages.length ]!="empty") {
try{
arrayImagesAllNumber++;
arrayImagesAll[arrayImagesAllNumber] = arrayImages[position % arrayImages.length];
if (arraySoundsPath[position % arraySoundsPath.length]!="empty") {
var monSon:Sound = new Sound();
monSon.addEventListener( IOErrorEvent.IO_ERROR , SoundError );
try {
requestSound.url = arraySoundsPath[position % arraySoundsPath.length];
try {
monSon.load(requestSound);
}
catch(IOError){}
arraySounds[arrayImagesAllNumber % arraySounds.length] = monSon;
} catch (e:Error) {}
}
} catch(Error){}
}
}

function addImageParamInArray(position:int):void {

if (arrayParams[position]!="empty") {

try{
arrayImagesAllNumber++;
arrayImagesAll[arrayImagesAllNumber] = arrayParams[position];

if (arrayParams[position+1]!="empty") {
var monSon2:Sound = new Sound();
monSon2.addEventListener( IOErrorEvent.IO_ERROR , SoundError );
try {
requestSound.url = arrayParams[position+1];
try {
monSon2.load(requestSound);
}
catch(IOError){}
arraySounds[arrayImagesAllNumber] = monSon2;
} catch (e:Error) {}
}
} catch(Error) {}
}
}

function addImageStatic(pEvt:MouseEvent):void {

var position:Number = ClicNumber;
// I set a limit to the number of displayed images
if (nbrImagesDisplayed >= 100 ) {
containerLoader.removeChildAt(0);
nbrImagesDisplayed--;
}

if (nbrImagesDisplayed < 100 ) {
var LoaderTweenImage:LoaderTween = new LoaderTween();

LoaderTweenImage.chargeur.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR , imageError );
LoaderTweenImage.chargeur.contentLoaderInfo.addEventListener( Event.COMPLETE, finishImage);
containerLoader = new Sprite();
// Initialisation of the tweens (to avoid errors when we stop the tweens)
LoaderTweenImage.tweenX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenY = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleY= new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenXX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenYY = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleXX = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenScaleYY= new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenXinterception = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );
LoaderTweenImage.tweenYinterception = new Tween(LoaderTweenImage,"x", Regular.easeOut, LoaderTweenImage.x , LoaderTweenImage.x, 0.01, true );

containerLoader.name = LoaderTweenImage.name = LoaderTweenImage.chargeur.name = (arrayImagesAllNumber+1).toString();

containerLoader.addChild(LoaderTweenImage);

containerLoader.addEventListener( MouseEvent.MOUSE_DOWN, clicImages, true );

var varX:Number;

if (arrayImagesAll[position % arrayImagesAll.length]!="empty") {

try{
arrayImagesAllNumber++;
arrayImagesAll[arrayImagesAllNumber] = arrayImagesAll[position % arrayImagesAll.length];
requestImage.url = arrayImagesAll[ position%arrayImagesAll.length];
try {
LoaderTweenImage.chargeur.load(requestImage);

}
catch(IOError){}

if (arraySounds[position % arraySounds.length]!="empty") {
var monSon:Sound = new Sound();
monSon.addEventListener( IOErrorEvent.IO_ERROR , SoundError );
try {
arraySounds[arrayImagesAllNumber % arraySounds.length] = arraySounds[position % arraySounds.length];
try {
//arraySounds[position] = arraySounds[position%arrayImagesAllNumber+1];
mainSoundChan = arraySounds[arrayImagesAllNumber % arraySounds.length].play(0,0,trans);
} catch (e:Error) {}
} catch (e:Error) {}
}
} catch(Error){}

if (int(arrayParams[1]) == 1 ) {
// Place the images below the previous images
mainContainer.addChildAt(containerLoader,0);
} else {
// Place the images on top of the previous images
mainContainer.addChild(containerLoader);
}
nbrImagesDisplayed++;
ClicNumber++;
}

containerLoader.buttonMode = true;
LoaderTweenImage.chargeur.scaleX = LoaderTweenImage.chargeur.scaleY = 1;
}
offsetX = 200;
offsetY = 150;

containerLoader.x = pEvt.stageX;
containerLoader.y = pEvt.stageY;
// Param2 : Image still or slightly moving
switch (arrayParams[2]) {

case "0" :
break;

case "empty" :
tempX = LoaderTweenImage.chargeur.scaleX;
tempY = LoaderTweenImage.chargeur.scaleY;
LoaderTweenImage.tweenScaleXX = new Tween(LoaderTweenImage.chargeur, "scaleX", Regular.easeOut,tempX ,tempX+Math.random()*0.1, Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleYY = new Tween(LoaderTweenImage.chargeur, "scaleY", Regular.easeOut,tempY ,tempY+Math.random()*0.1, Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenScaleYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
posX = LoaderTweenImage.chargeur.x;
posY = LoaderTweenImage.chargeur.y;
LoaderTweenImage.tweenXX = new Tween(LoaderTweenImage.chargeur, "x", Regular.easeOut,posX ,posX+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenYY = new Tween(LoaderTweenImage.chargeur, "y", Regular.easeOut,posY ,posY+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
break;

default :
// the difference with the "empty" case is that I use the param2 also to set the variation of the size (param2 could be 100)
tempX = LoaderTweenImage.chargeur.scaleX;
tempY = LoaderTweenImage.chargeur.scaleY;
LoaderTweenImage.tweenScaleXX = new Tween(LoaderTweenImage.chargeur, "scaleX", Regular.easeOut,tempX ,tempX+Math.random()*0.1*int(arrayParams[2]), Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleYY = new Tween(LoaderTweenImage.chargeur, "scaleY", Regular.easeOut,tempY ,tempY+Math.random()*0.1*int(arrayParams[2]), Math.random()*0.6+1, true);
LoaderTweenImage.tweenScaleXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenScaleYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
posX = LoaderTweenImage.chargeur.x;
posY = LoaderTweenImage.chargeur.y;
LoaderTweenImage.tweenXX = new Tween(LoaderTweenImage.chargeur, "x", Regular.easeOut,posX ,posX+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenYY = new Tween(LoaderTweenImage.chargeur, "y", Regular.easeOut,posY ,posY+Math.random()*30-15, Math.random()*0.6+1, true);
LoaderTweenImage.tweenXX.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
LoaderTweenImage.tweenYY.addEventListener(TweenEvent.MOTION_FINISH, TweenYoyo);
break;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
/// Functions resize images
//////////////////////////////////////////////////////////////////////////////////////////////
function finishImage(pEvt:Event):void {
var varSigne:Number = Math.random()*0.2 - 0.1;
var factor:Number = 1;

// For this template none of the images are flipped but we could for example use the param10 this way:
// Exple: Param10 : defined if the image is horizontally flipped
/*if (arrayParams[10]!="empty") {
switch ( int(arrayParams[10]) ) {
case 0 :// 0: randomly horizontally flipped
if ( varSigne < 0 ) {
factor = -1;
}
break;
case 1 :// 1: no flip
break;
case 2 :// 2: flipped horizontally
factor = -1;
break;
default :
break;
}
}*/
var Width:Number = DisplayObject(pEvt.target.content).width;
var Height:Number = DisplayObject(pEvt.target.content).height;

// We choose that the image is no more than a sixth of the whole movie
var scale1:Number = (800/ImageSize)/Width;
var scale2:Number = (600/ImageSize)/Height;

var scale:Number;
scale = scale1;
if ( scale1 > scale2) {
scale = scale2;
}
DisplayObject(pEvt.target.content).scaleX = factor*scale*(1+varSigne);
DisplayObject(pEvt.target.content).scaleY = scale*(1+varSigne);
DisplayObject(pEvt.target.content).x = DisplayObject(pEvt.target.content).x-Width*(factor)*scale*(1+varSigne)/2;
DisplayObject(pEvt.target.content).y = DisplayObject(pEvt.target.content).y-Height*scale*(1+varSigne)/2;
}

function finishBackground(pEvt:Event):void {
var Width:Number = DisplayObject(pEvt.target.content).width;
var Height:Number = DisplayObject(pEvt.target.content).height;

var scale1:Number = (800)/Width;
var scale2:Number = (600)/Height;

var scale:Number;
scale = scale2;
if ( scale1 > scale2) {
scale = scale1;
}
DisplayObject(pEvt.target.content).scaleX = DisplayObject(pEvt.target.content).scaleY = scale;
}

//////////////////////////////////////////////////////////////////////////////////////////////
/// Functions Tween
//////////////////////////////////////////////////////////////////////////////////////////////
function tweenFunction(pEvt:MouseEvent):void {
//trace("tweenFunction :" + pEvt.currentTarget.getChildAt(0));
var vardirection:Number = 1;
var varduration:Number = Math.random()*3+2;
if (pEvt.currentTarget.scaleX < 0) {
vardirection = -1;
}
pEvt.currentTarget.getChildAt(0).tweenX.removeEventListener(TweenEvent.MOTION_FINISH , motionStop );
pEvt.currentTarget.getChildAt(0).tweenY.removeEventListener(TweenEvent.MOTION_FINISH , motionStop );
pEvt.currentTarget.getChildAt(0).tweenX.stop();
pEvt.currentTarget.getChildAt(0).tweenY.stop();
pEvt.currentTarget.getChildAt(0).tweenX = new Tween(pEvt.currentTarget,"x", Regular.easeOut, pEvt.currentTarget.x ,Math.random()*800, varduration+0.1, true );
pEvt.currentTarget.getChildAt(0).tweenY = new Tween(pEvt.currentTarget,"y", Regular.easeOut, pEvt.currentTarget.y ,Math.random()*600, varduration, true );
pEvt.currentTarget.getChildAt(0).tweenX.addEventListener(TweenEvent.MOTION_FINISH , motionStop );
}

function TweenYoyo(pEvt:TweenEvent):void {
pEvt.currentTarget.yoyo();
}

function motionStop(pEvt:TweenEvent):void {
//pEvt.currentTarget.obj.addEventListener( MouseEvent.MOUSE_DOWN, clicImages );
pEvt.currentTarget.removeEventListener(TweenEvent.MOTION_FINISH , motionStop );
}

///////////////////////////////////////////
/// Functions imageError and SoundError
function imageError(pEvt:IOErrorEvent):void {
trace("An image is not correctly defined with the manager.");
if (MovieClip(parent.parent)!=null) {
MovieClip(parent.parent).traceAdvice("An image is not correctly defined with the manager.");
}
}

function SoundError(pEvt:IOErrorEvent):void {
trace("A Sound is not correctly defined with the manager.");
if (MovieClip(parent.parent)!=null) {
MovieClip(parent.parent).traceAdvice("A Sound is not correctly defined with the manager.");
}
}

///////////////////////////////////////////
/// Initialisation
init();

Références et liens References and links
A venir Soon

Introduction
1. Player ¦ 2. Games ¦ 3. Manager ¦ 4. Developers ¦ 5. Thanks ¦ 6. Contribution ¦ 7. Make a donation
A. Update your computer ¦ B. Set the microphone ¦ C. Links
Télécharger / Download

Handi Computer Games : update 25 July 2009