| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 
 | stop();
_root.prevloc=null;
monitor.onEnterFrame=function(){
//Cette fonction vérifie en permanence où se trouve le focus
//de manière à démarrer et stopper des animations
 
	var loc=Selection.getFocus();		
	if(loc == null){
		userarea.gotoAndStop(1);
		passarea.gotoAndStop(1);
		pwdtext.gotoAndStop(1);
		usertext.gotoAndStop(1);
	}
	if(loc == "_level0.user" and loc != _root.prevloc){
		if(_root.ErrorContainer != undefined){
			_root.ErrorContainer.removeMovieClip();
		}
		usertext.gotoAndPlay(2);
		pwdtext.gotoAndStop(1);
		userarea.play();
		passarea.gotoAndStop(1);
	}
 
	if(loc == "_level0.password" and loc != _root.prevloc){		
		if(_root.ErrorContainer != undefined){
			_root.ErrorContainer.removeMovieClip();
		}
		usertext.gotoAndStop(1);
		pwdtext.gotoAndPlay("2");
		userarea.gotoAndStop(1);
		passarea.play();
	}
 
	_root.prevloc=loc;
}
 
valider.onPress=function(){		
//Cette fonction exécute le script PHP et capture toute erreur possible
		if(userpass.length <= 5){
			var PhpObject= new LoadVars();
			PhpObject.username=_root.username;
			PhpObject.userpass=_root.userpass;
			PhpObject.onLoad=function(success){
				if(success){
					if(this.error != undefined){
						ShowError(this.error);
					}
					else{
						_root.gotoAndPlay(2);
					}
				}
				else{
					ShowError("Erreur durant le chargement");
				}
			}
 
			if(firstvisit.checked){
				PhpObject.new_user=1;
			}
			PhpObject.sendAndLoad("http://localhost/testform/flashphp.php",PhpObject,"POST");	
		}
		else{
			ShowError("Le mot de passe doit faire moins de 6 car.");
		}
 
 
 
}
//Cette fonction crée des MC dynamiquement pour afficher l'erreur
//Elle crée un MC par lettre composant le message d'erreur, le tout dans un MC vide
function ShowError(errmsg){
	if(_root.ErrorContainer != undefined){
		_root.ErrorContainer.removeMovieClip();
	}
	_root.createEmptyMovieClip("ErrorContainer",2);
	_root.ErrorContainer._x=10;
	_root.ErrorContainer._y=90;	
	_root.ErrorContainer.attachMovie("errormsgMC","ErrorLetter0",10);
	_root.ErrorContainer.errorletter0.letterMC.letter.text=errmsg.charAt(0);
	_root.ErrorContainer.errorletter0._x=0;
	_root.ErrorContainer.errorletter0._y=0;	
 
	for(i=1;i < errmsg.length;i++){
		_root.ErrorContainer.ErrorLetter0.duplicateMovieClip("ErrorLetter"+i,10+i);
		_root.ErrorContainer["ErrorLetter"+i].letterMC.letter.text=errmsg.charAt(i); 
		_root.ErrorContainer["ErrorLetter"+i]._x=(Xpos+(int(i)*8));
		_root.ErrorContainer["ErrorLetter"+i]._y=0;
 
	}
 
 
} | 
Partager