• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

text input as3 to html5

Community Beginner ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

///////////////////////////////////////////////////// RANDOM
function getRandomSequence2(min: int, max: int): Array {
if (min > max) throw new Error("Max value should be greater than Min value!");
if (min == max) return [min];
var values: Array = [];
for (var i: int = min; i <= max; i++) values.push(i);
var result: Array = [];
while (values.length > 0) result = result.concat(values.splice(Math.floor(Math.random() * values.length), 1));
return result;
}
var randomicos: Array = new Array();
randomicos = getRandomSequence2(1, 10);//PEGA O X
/////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////

String.prototype.removeSpaces = function ():String {
var str = this;
while(str.indexOf(' ') > -1)
str = str.split(' ').join(' ');
return str;
}
function textRemoveSpaces(e:Event) {
var current = e.currentTarget;
current.text = current.text.removeSpaces();
}
txt.addEventListener('change', textRemoveSpaces); //Deixa letras maiusculas

///////////////////////////////////////////////////////////////////////////////////////

import flash.ui.Multitouch;
import flash.events.Event;

stop();

//////////////////////////////////////////////////////////////////////////
txt.addEventListener(Event.CHANGE, toUpperCase)

function toUpperCase(evt: Event): void {

evt.target.text = evt.target.text.toUpperCase();
}

//palavras acentos.
txt.restrict = "A-Z\\-\u00C0-\u00FF";
//////////////////////////////////////////////////////////////////////////
var contador:Number=0;
var errado:Number=0;

var respostas:Array=new Array(
"","CARLA","BRINCANDO","ESCUTEI","MIADO","ESCOLHER","BRASIL","URNA","NAÇÃO","INDEPENDENTE","FORMA");

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function INICIO():void{
txt.maxChars=respostas[randomicos[contador]].length+1;
txt.text="";
txt.type='input';
txt.textColor=0xF5B13B;
//this.aparece.gotoAndStop(randomicos[contador])
trace("resposta= "+respostas[randomicos[contador]])
}

INICIO();

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

verificar.addEventListener('click',fnVerificar)
verificar.buttonMode=true;
/*DIGITA.alpha=0;*/

function fnVerificar(e:Event):void{

var qlq:Array=new Array(txt.text)
qlq[0]= qlq[0].replace(/^[\s|"]+|[\s|"]+$/gs, '');//FUNÇÃO QUE TIRA O ESPAÇO DO INICIO E DO FIM

if(qlq[0]==respostas[randomicos[contador]]){
trace("acertou")
txt.type='dynamic'
txt.textColor=0x009900;
//++contador;
verificar.removeEventListener('click',fnVerificar)
verificar.alpha=0.2;
}
else{
//++errado;
trace("errou")
//txt.type='dynamic'
//txt.textColor=0xFF0000;
}


}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

Views

186

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 14, 2020 Jul 14, 2020

Copy link to clipboard

Copied

you have a question or are you looking for someone to work for you?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

I have a question!

I can't do this programming in html5 canvas only on as3!

But I'm migrating to html5 canvas and I'm having difficulty in this part of the input text with restrict maxchars and take space from the beginning.

I need help with this cod. If you can help me I appreciate it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

function removeLeadFollowSpacesF(s){

return s.trim();

}

function removeAllSpacesF(s){

return s.split(" ").join("");

}

function truncateF(s,maxChar){

return s.substr(0,maxChar);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 15, 2020 Jul 15, 2020

Copy link to clipboard

Copied

Thank you helped me a lot that God doubles you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 16, 2020 Jul 16, 2020

Copy link to clipboard

Copied

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 22, 2020 Jul 22, 2020

Copy link to clipboard

Copied

how to use it in real time when typing and how would it look?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 23, 2020 Jul 23, 2020

Copy link to clipboard

Copied

LATEST

use an "input" listener on your textfield to call those functions.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines