Animation molécules, avec : duplication simple -> destruction / rotation / mouvement / changement alpha

Description

Animation de molécules carrée, la forme importe peu, c'est l'action script qui est important, vous pouvez changer le symbole par quelque chose de plus joli.

L'animation charge un nombre initial de molécule -> explosion de celle-ci qui sortent de l'écran. Le but de ce genre d'animation c'est d'explorer un univers complexe et trés chargé.

Les molécules se déplacent aléatoirement, avec des vitesses aléatoires, sortent de l'écran puis reviennent, se dupliquent aléatoirement comme pour laisser une trace qui s'estompe.

Tout est paramétrable, et 100% action script. Vous pouvez aussi mettre l'animation en fond pour animer une baniére ou autre.

Source / Exemple :


// Sur le FRAME 1 :
var acceleration = 10;
var max_dist = 1000;
var max_out = 10;
var rotate_speed = 10;
var max_alpha = 80;
var min_alpha = 40;
var speed_alpha = 6;

_root.totalDepht = 50;

for (i=0; i<_root.totalDepht-1; i++) {
	_root["clipBouge"].duplicateMovieClip("cp"+i, i+1);
	setProperty("cp" + i, _x, random(600));
	setProperty("cp" + i, _y, random(400));
	setProperty("cp" + i, _alpha, random(max_alpha-min_alpha)+min_alpha);
}
stop();

// Dans la MovieClip clipBouge -> FRAME 1
onClipEvent (enterFrame) {
	if (this.mode==1) {
		if (this._alpha>0) {
			this._alpha -= 10;
		} else {
			this.removeMovieClip();
		}
		return false;
	}
	if (this.go_x<1 || (this._x == this.go_x && this._y == this.go_y) || (this.a_x<1 && this.a_y<1)) {
		this.rgo_x = random(_root.max_dist);
		this.rgo_y = random(_root.max_dist);
		this.go_x += random(this.rgo_x)-(this.rgo_x/2);
		this.go_y += random(this.rgo_y)-(this.rgo_y/2);
		if (this.go_x < -10 || this.go_y < -10 || this.go_x>600 || this.go_y>400) {
			this.is_out +=1
			this.b_out = true;
			if (this.is_out>_root.max_out) {
				this.is_out = 0;
				this.go_x = random(600);
				this.go_y = random(400);				
			}
		} else {
			this.is_out = 0;
			this.b_out = false;
		}
		this.distance = Math.abs(this.go_x - this._x) / Math.abs(this.go_y - this._y);
		this.inc = this.distance / _root.acceleration;
		this.acc = _root.acceleration;
		this.bouge += 1;
		if (this.bouge % 10 == 0 && this.b_out == false) {
			var nom = "f_"+this._name+"_"+this.bouge;
			_root.totalDepht += 1;
			this.duplicateMovieClip(nom, _root.totalDepht);
			setProperty(nom, _x, this._x);
			setProperty(nom, _y, this._y);
			this._parent[nom].mode = 1;
		}
	}
	
	this._parent["btnClip"]._rotation += random(_root.rotate_speed);
	
	this._parent._alpha += random(_root.speed_alpha) - (_root.speed_alpha/2);
	
	if (this._parent._alpha<_root.min_alpha) {
		this._parent._alpha = _root.min_alpha;
	}
	
	if (this._parent._alpha>_root.max_alpha) {
		this._parent._alpha = _root.max_alpha;
	}
	
	if (this._parent["btnClip"]._rotation>360) {
		this._parent["btnClip"]._rotation = 0;
	}
	
	this.a_x = (this.go_x-this._x) / this.acc;
	this._x += a_x;
	this.a_y = (this.go_y-this._y) / this.acc;
	this._y += a_y;
}

Conclusion :


Aucun bug connu pour le moment, si vous avez utilisé cette animation vous pouvez m'envoyer un lien, je le donnerais en exemple sur cette page.

Bonne prog à tous, akh

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.