-
Resetting input texts, saving and loading them
Hello you all,
I recently stumbled upon a code I've been tweaking in order to function according to my needs. I believe it is in AS1 or so. I am not a flash programmer, I'm mostly a designer, and have no programmer at the time with a deadline about to be met lol.
Either way, this is for a game on which users listen to a song and write their names in an input text box. So far, so good.
But I want people to be able to reset it, let people save their answers to continue at a later time (that includes having a function to load their answers) and, if possible, have a button that shows all the answers in the input boxes (with a "loser" message loading in an MC).
Would that be possible? I tried it in many different ways but nothing seemed to work.
Thank you in advance for any help, which will be much appreciated.
This is the code
Code:
_root.fundo2.swapDepths(2);
function criabloco()
{
_root.createEmptyMovieClip("bloco", 0);
bloco._x = 0;
bloco._y = 0;
var __reg3 = 0;
for (;;)
{
if (__reg3 >= nitens)
{
return;
}
n = __reg3 + 1;
nm = "mc" + n;
nmb = "bt" + n;
bloco.attachMovie("mc", nm, n);
bloco[nm]._x = __reg3 * (largura + sep_larg);
bloco[nm]._y = 0;
bloco[nm].num = n;
bloco[nm].img.attachMovie("i" + n, "img" + n, n);
bloco[nm].resp = "";
bloco[nm].campo.tabIndex = n;
centraliza(bloco);
bloco[nm].campo.onChanged = function ()
{
confere_respostas();
totaliza();
}
;
arquivo = "s" + bloco[nm].num;
bloco[nm].s = new Sound();
bloco[nm].s.attachSound(arquivo);
bloco[nm].s.setVolume(50);
bloco[nm].btsom.onRelease = function ()
{
para_sons();
this._parent.s.start(0, 0);
}
;
bloco[nm].campo.onSetFocus = function ()
{
if (this._parent._currentframe == 1)
{
this._parent.gotoAndStop(4);
}
}
;
bloco[nm].campo.onKillFocus = function ()
{
if (this._parent._currentframe == 4)
{
this._parent.gotoAndStop(1);
}
}
;
++__reg3;
}
}
function criamenu()
{
_root.createEmptyMovieClip("menu", 500);
menu._x = 28.5;
menu._y = 508;
menu.attachMovie("menu_bg", "fundo", 0);
menu.fundo._x = -400;
menu.fundo._y = -24.7;
menu.fundo.onRollOver = function ()
{
this.useHandCursor = false;
}
;
var __reg3 = 0;
for (;;)
{
if (__reg3 >= nitens)
{
return;
}
xis = __reg3 + 1;
nmi = "mc" + xis;
nm = "bt" + xis;
menu.attachMovie("bt", nm, xis);
menu[nm]._x = __reg3 % bpl * (bt_larg + bt_sep_larg);
menu[nm]._y = Math.floor(__reg3 / bpl) * (bt_alt + bt_sep_alt);
menu[nm].num = xis;
menu[nm].onRelease = function ()
{
moveto(bloco, _root.item_atual, this.num);
para_sons();
}
;
++__reg3;
}
}
function criacabecalho()
{
_root.createEmptyMovieClip("cabecalho", 3);
cabecalho.attachMovie("header", "head", 3);
cabecalho._x = 0;
cabecalho._y = 0;
}
function centraliza(item)
{
n = _root.item_atual;
novo_x = centro_x - ((largura + sep_larg) * n - (sep_larg + largura / 2));
novo_y = centro_y - item._height / 2;
item._x = novo_x;
item._y = novo_y;
}
function moveto(grupo, pos_atual, pos_novo)
{
if (pos_novo != pos_atual)
{
veloc = 3;
if (pos_atual < pos_novo)
{
direcao = 1;
}
else
{
direcao = -1;
}
novo = "mc" + pos_novo;
atual = "mc" + pos_atual;
x_novo = grupo._x + (grupo[atual]._x - grupo[novo]._x);
ativa_item(pos_novo);
grupo.onEnterFrame = function ()
{
dif_x = this._x - x_novo;
grupo._x = grupo._x - dif_x / veloc;
if (dif_x * direcao < 1)
{
dif_x = null;
delete this.onEnterFrame;
grupo._x = x_novo;
}
}
;
}
}
function respostas_validas()
{
bloco.mc1.valid = new Array("revenge");
bloco.mc2.valid = new Array("i cant forget", "i can\'t forget", "i can t forget");
bloco.mc3.valid = new Array("stay");
bloco.mc4.valid = new Array("im in love with love", "i\'m in love with love", "i m in love with love");
bloco.mc5.valid = new Array("its so cool", "it\'s so cool", "it s so cool");
bloco.mc6.valid = new Array("each time you break my heart");
bloco.mc7.valid = new Array("has to be");
bloco.mc8.valid = new Array("miss you");
bloco.mc9.valid = new Array("get up");
bloco.mc10.valid = new Array("keep the trance");
bloco.mc11.valid = new Array("liquid love");
bloco.mc12.valid = new Array("shake your head");
bloco.mc13.valid = new Array("be careful with my heart");
bloco.mc14.valid = new Array("let down your guard");
bloco.mc15.valid = new Array("across the sky");
bloco.mc16.valid = new Array("superpop", "super pop");
bloco.mc17.valid = new Array("little girl");
bloco.mc18.valid = new Array("laugh to keep from crying");
bloco.mc19.valid = new Array("the beast within");
bloco.mc20.valid = new Array("**** on the ground", "safe neighborhood", "safe neighbourhood");
bloco.mc21.valid = new Array("goodbye to innocence", "good bye to innocence");
bloco.mc22.valid = new Array("like a flower");
bloco.mc23.valid = new Array("hey you");
bloco.mc24.valid = new Array("the game");
bloco.mc25.valid = new Array("gambler");
bloco.mc26.valid = new Array("broken");
bloco.mc27.valid = new Array("you thrill me", "erotica");
bloco.mc28.valid = new Array("animal");
}
function confere_respostas()
{
var __reg2 = 0;
for (;;)
{
if (__reg2 >= nitens)
{
return;
}
y = __reg2 + 1;
nmb = "bt" + y;
nm = "mc" + y;
estado = 0;
tentativa = bloco[nm].resp;
tentativa = tentativa.toLowerCase();
var __reg1 = 0;
while (__reg1 < bloco[nm].valid.length)
{
if (tentativa == bloco[nm].valid[__reg1])
{
estado = estado + 50;
}
if (tentativa != bloco[nm].valid[__reg1])
{
estado = estado - 1;
}
++__reg1;
}
if (estado > 0)
{
bloco[nm].gotoAndStop(2);
menu[nmb].gotoAndStop(2);
}
if (estado < 0)
{
bloco[nm].gotoAndStop(3);
menu[nmb].gotoAndStop(3);
}
if (tentativa == "")
{
bloco[nm].gotoAndStop(1);
menu[nmb].gotoAndStop(1);
}
estado = 0;
++__reg2;
}
}
function totaliza()
{
certas = 0;
var __reg2 = 0;
while (__reg2 < nitens)
{
b = __reg2 + 1;
if (bloco["mc" + b]._currentframe == 2)
{
certas = certas + 1;
}
++__reg2;
}
porcento = Math.round(certas / nitens * 100);
pct_acerto = porcento + "% completo";
show_certas = "Acertos: " + certas + " de " + nitens;
if (certas == nitens)
{
_root.attachMovie("congrat", "tela_final", 20000);
tela_final._x = 0;
tela_final._y = 0;
}
}
function para_sons()
{
var __reg1 = 0;
for (;;)
{
if (__reg1 >= nitens)
{
return;
}
bloco["mc" + (__reg1 + 1)].s.stop();
++__reg1;
}
}
function ativa_item(z)
{
_root.item_atual = z;
var __reg2 = 0;
for (;;)
{
if (__reg2 >= nitens)
{
return;
}
ind = __reg2 + 1;
btn = "bt" + ind;
if (menu[btn]._currentframe != 2 && menu[btn]._currentframe != 3)
{
if (menu[btn]._currentframe == 1 && menu[btn].num == z)
{
menu[btn].gotoAndStop(4);
}
else
{
menu[btn].gotoAndStop(1);
}
}
++__reg2;
}
}
item_atual = 1;
nitens = 28;
ipl = nitens;
largura = 300;
altura = 165;
sep_larg = 80;
sep_alt = 0;
tela_larg = Stage.width;
tela_alt = Stage.height;
centro_x = 465;
centro_y = 330;
bt_larg = 30;
bt_alt = 30;
bt_sep_larg = 16;
bt_sep_alt = 16;
bpl = 14;
prox.onRelease = function ()
{
if (item_atual < nitens)
{
moveto(bloco, item_atual, item_atual + 1);
}
para_sons();
}
;
ante.onRelease = function ()
{
if (item_atual > 1)
{
moveto(bloco, item_atual, item_atual - 1);
}
para_sons();
}
;
-
I figured out how to reset, save and load. I am still having troubles with making all the answers appear. If anyone has an idea of how to make it, it'll be greatly appreciated.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|