Sperando di aver ben interpretato il problema ti ho riscritto il codice che puoi applicare nel seguente modo
Questo codice non va scritto sull'oggetto ma sulla frame della time line corrispondente al pulsante che ho ipotizzato di istanziare "btn", diversamente puoi copiare sull'oggetto solo la prima parte modificandola così
on(release){ read_external() }
il vantaggio di creare dell funzioni è quello di poterle richiamare in qualsiasi momento e da più punti. Vedi ad esempio la reset_fileds() per azzerare i campi
Inoltre suggerisco di far prima precedere loader.onLoad() al loader.load()
Ciao
Codice PHP:
btn.onRelease=function(){
read_external()
}
function read_external(){
loader = new LoadVars();
loader.onLoad = function(success) {
if(success){
if(this.ok){
reset_fields()
j=1
while(this["username"+j] != undefined){
_root.username.htmlText += this["username" + j];
_root.password.htmlText += this["password" + j);
_root.email.htmlText += this["email" + ];
_root.name.htmlText += this["name" + j];
_root.surname.htmlText += this["surname" + j];
_root.address.htmlText += this["address" + j];
_root.sesso.htmlText += this["sesso" + j];
_root.capelli.htmlText += this["capelli" + j];
_root.occhi.htmlText += this["occhi" + j];
j++
}
_root.output.text = "ok";
}else{
reset_fileds()
}
}else{
trace("errore caricamento dati esterni: file flash-estrarre.php"
}
}
loader.load("flash-estrarre.php");
}
function reset_fields(){
_root.username.htmlText = "";
_root.password.htmlText = "";
_root.email.htmlText = "";
_root.name.htmlText = "";
_root.surname.htmlText = "";
_root.address.htmlText = "";
_root.sesso.htmlText = "";
_root.capelli.htmlText = "";
_root.occhi.htmlText = "";
}