korvina Posted June 5, 2009 at 08:34 PM Report #270296 Posted June 5, 2009 at 08:34 PM pessoal, alguém sabe porque é que isto não funciona?!?! ao que parece mesmo com o focus na input_txt quando lá escrevo não é validado o 1º caracter digitado... o que quero fazer é o seguinte: mal é digitado um ID na input_txt é enviado para o php para ver se existe algum produto na bd com esse id... stage.focus = input_txt; var variables:URLVariables = new URLVariables(); //build the varSend variables var varSend:URLRequest = new URLRequest("existe.php"); varSend.method = URLRequestMethod.POST; varSend.data = variables; //build the varLoad variables var varLoader:URLLoader = new URLLoader; varLoader.dataFormat = URLLoaderDataFormat.VARIABLES; varLoader.addEventListener(Event.COMPLETE,completeHandler); // Add event listener for text input click input_txt.addEventListener(TextEvent.TEXT_INPUT, ValidateAndSend); //handler for php completion and return of status function completeHandler(e:Event):void{ //load the response from php status_txt.text = e.target.data.return_msg; } // function ValidateAndSend function ValidateAndSend (event:TextEvent):void { status_txt.textColor=0xFF0000; status_txt.alpha = .7; // validate fields status_txt.text = ""; // All is good, send the data now to PHP // ready the variables in our form for sending variables.codBarras = input_txt.text; trace(variables); // Send the data to PHP now varLoader.load(varSend); } // close validate and send function o erro é este... por exemplo digitando 5 na input_txt no trace aparece codBarras= ao digitar de novo outro 5... na input fica 55 e no trace codBarras=5 desde já agradeço... edit: já resolvi 🙂 troquei as linhas a bold para: input_txt.addEventListener(Event.CHANGE, ValidateAndSend); function ValidateAndSend (event:Event):void { ...} já agora... como faço para mal entro numa frame ele executar um bocado de codigo!? em AS3...
pouic Posted June 6, 2009 at 12:16 PM Report #270352 Posted June 6, 2009 at 12:16 PM Viva, Para executar um código podes sempre chamar uma função.... executaCodigo(); function executaCodigo():void{ trace("O meu código vai estar aqui"); }
korvina Posted June 6, 2009 at 01:47 PM Author Report #270381 Posted June 6, 2009 at 01:47 PM Viva, Para executar um código podes sempre chamar uma função.... executaCodigo(); function executaCodigo():void{ trace("O meu código vai estar aqui"); } obrigado funciona 😛
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now