I have an animation with 11 layers, 4 of them have a regular time line, 4 others have a actionscript animation(moving left to right and replacing left when disappear(they are clouds)), 1 other is just a layers for actions, and the last 2 contains a MovieClip named “fond_mc” and “verdure_mc”(i’m french, in english: “background_mc” and “grass_mc”).
my script is:
fond_mc.stop();
verdure_mc.stop();
nuage1_mc.addEventListener(Event.ACTIVATE, initialisation); // nuage = cloud
nuage4_mc.addEventListener(Event.ACTIVATE, initialisation);
nuage2_mc.addEventListener(Event.ACTIVATE, initialisation);
nuage3_mc.addEventListener(Event.ACTIVATE, initialisation);
function initialisation(e:Event):void {
e.currentTarget.vitesse = Math.floor(Math.random()*4)+1; // Génération d'un nombre entre 1 et 4 (compris)
var positionDepart:Number = Math.floor(Math.random()*990); // Génération d'un nombre entre 0 et 990
e.currentTarget.x = positionDepart;
e.currentTarget.addEventListener(Event.ENTER_FRAME, mouvement);
}
function mouvement(e:Event):void {
if(e.currentTarget.x <= 990)
e.currentTarget.x += e.currentTarget.vitesse;
else {
e.currentTarget.vitesse = Math.floor(Math.random()*4)+1; // Génération d'un nombre entre 1 et 4 (compris)
e.currentTarget.x = - Math.floor(Math.random()*100) - e.currentTarget.width;
}
}
The first 2 lines is freaking me of cause they don’t work like they should, and fond_mc and verdure_mc keep playing.
Any ideas?