Flash store (only one problem.Suming values) please help
- rmarin
- Newbie


- Joined: Dec 10, 2008
- Posts: 5
- Status: Offline
Hi all
googling for my problem i end up here and i rapid noticed this is a great place and so many things you all helped solve... hope i can help also...
i have a flash store that loads from xmls..
all is working well but i cant solve the sum/removing of the fields(products)
it returns NaN error
or just the last added product
my_nstep.value is a drop down where we chose qty
valor.text is the price in the description of the product
myDP_array creats the product, quant, and price
the sum is here:
this is the complete code if it helps
googling for my problem i end up here and i rapid noticed this is a great place and so many things you all helped solve... hope i can help also...
i have a flash store that loads from xmls..
all is working well but i cant solve the sum/removing of the fields(products)
it returns NaN error
or just the last added product
my_nstep.value is a drop down where we chose qty
valor.text is the price in the description of the product
myDP_array creats the product, quant, and price
the sum is here:
Code: [ Select ]
botao.onPress = function ()
{
fim.enabled = true;
var _loc2 = Number(my_nstep.value * valor.text);
myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
my_dg.dataProvider = myDP_array;
var _loc1 = Number(soma.text) + _loc2;
soma.text = _loc1;
total.text = _loc1;
numero = numero + 1;
};
{
fim.enabled = true;
var _loc2 = Number(my_nstep.value * valor.text);
myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
my_dg.dataProvider = myDP_array;
var _loc1 = Number(soma.text) + _loc2;
soma.text = _loc1;
total.text = _loc1;
numero = numero + 1;
};
- botao.onPress = function ()
- {
- fim.enabled = true;
- var _loc2 = Number(my_nstep.value * valor.text);
- myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
- my_dg.dataProvider = myDP_array;
- var _loc1 = Number(soma.text) + _loc2;
- soma.text = _loc1;
- total.text = _loc1;
- numero = numero + 1;
- };
this is the complete code if it helps
Code: [ Select ]
function preencher()
{
var _loc2 = container.attachMovie("item_mc", "i[" + coluna + "][" + linha + "]", container.getNextHighestDepth());
_loc2._x = Math.round(coluna * _loc2._width + coluna * 5);
_loc2._y = Math.round(linha * _loc2._height + linha * 5);
_loc2.url_fotop = dados[i].attributes.fotop;
_loc2.url_foto = dados[i].attributes.foto;
_loc2.nome.text = dados[i].attributes.nome;
_loc2.info = dados[i].attributes.desc;
_loc2.valor.text = dados[i].attributes.preco;
carregar.loadClip(dados[0].attributes.fotop, loader);
nome.text = dados[0].attributes.nome;
valor.text = dados[0].attributes.preco;
info.text = dados[0].attributes.desc;
_loc2.onRelease = function ()
{
carregar.loadClip(this.url_fotop, loader);
nome.text = this.nome.text;
valor.text = this.valor.text;
info.text = this.info;
};
mcs.push(_loc2);
carregar.loadClip(_loc2.url_fotop, _loc2.foto);
i++;
coluna++;
if (coluna >= qc && linha >= ql - 1)
{
return;
} // end if
if (coluna == qc && linha < ql)
{
coluna = 0;
++linha;
} // end if
if (i < len)
{
preencher(coluna, linha);
} // end if
} // End of the function
function removeAll()
{
var _loc1 = 0;
var _loc2 = mcs.length;
while (_loc1 < _loc2)
{
mcs[_loc1].removeMovieClip();
++_loc1;
} // end while
mcs = [];
} // End of the function
function ativar(num)
{
var i = 0;
while (i < qp)
{
if (num != i)
{
eval("paginacao.p" + i).enabled = true;
}
else
{
eval("paginacao.p" + i).enabled = false;
} // end else if
++i;
} // end while
} // End of the function
function criaPaginacao()
{
var _loc5 = qtd;
var _loc2 = 0;
var _loc4 = qp;
while (_loc2 < _loc4)
{
var _loc3 = paginacao.attachMovie("pag_mc", "p" + _loc2, paginacao.getNextHighestDepth());
_loc3._x = Math.round(_loc2 * _loc3._width + _loc2);
_loc3.idpag = _loc2 * (qc * ql);
_loc3.n_txt.text = _loc2 + 1;
_loc3.atual = _loc2;
_loc3.onRelease = function ()
{
removeAll();
ativar(this.atual);
i = this.idpag;
coluna = 0;
linha = 0;
preencher();
};
++_loc2;
} // end while
paginacao.p0.onRelease();
} // End of the function
var i = 0;
var coluna = 0;
var linha = 0;
var len = 0;
var dados;
var carregar = new MovieClipLoader();
var fotos = new XML();
var qc = 4;
var ql = 2;
var qp = 0;
var mcs = [];
fotos.ignoreWhite = true;
fotos.load("loja.xml");
fotos.onLoad = function ()
{
if (fotos.loaded == true)
{
dados = this.firstChild.childNodes;
len = dados.length;
qp = Math.ceil(len / (qc * ql));
if (qp > 1)
{
criaPaginacao();
delete prencher();
}
else if (qp <= 1)
{
preencher();
delete criaPaginacao();
paginacao.unloadMovie();
} // end if
} // end else if
};
stop ();
my_dg.setStyle("alternatingRowColors", [16777215, 16250871]);
my_dg.setStyle("borderStyle", "solid");
var myDP_array = new Array();
var conta = new Number();
var numero = new Number();
my_dg.resizableColumns = false;
my_dg.sortableColumns = false;
deleta.enabled = false;
fim.enabled = false;
my_dg.onLoad = function ()
{
myDP_array.push({Produto: algo, Qtd: algo, Preço: algo});
my_dg.dataProvider = myDP_array;
var _loc1 = my_dg.getColumnAt(0);
_loc1.width = 140;
my_dg.removeAll();
};
botao.onPress = function ()
{
fim.enabled = true;
var _loc2 = Number(my_nstep.value * valor.text);
myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
my_dg.dataProvider = myDP_array;
var _loc1 = Number(soma.text) + _loc2;
soma.text = _loc1;
total.text = _loc1;
numero = numero + 1;
};
fim.onPress = function ()
{
bt1.enabled = false;
bt2.enabled = false;
bt3.enabled = false;
bt4.enabled = false;
botao.enabled = false;
fim.enabled = false;
my_nstep.enabled = false;
check._visible = true;
produtos._visible = false;
container.unloadMovie();
paginacao.unloadMovie();
};
myGridListener = new Object();
myGridListener.change = function (eventObj)
{
deleta.enabled = true;
var eventSource = Number(my_dg.selectedItem.Preço);
deleta.onPress = function ()
{
if (my_dg.selectedIndex != undefined)
{
my_dg.removeItemAt(my_dg.selectedIndex);
var _loc2 = Number(eventSource);
var _loc1 = total.text - eventSource;
total.text = _loc1;
deleta.enabled = false;
numero = numero - 1;
if (numero == 0)
{
fim.enabled = false;
} // end if
} // end if
};
};
my_dg.addEventListener("change", myGridListener);
if (numero == 0)
{
deleta.enabled = false;
}
else
{
deleta.enabled = true;
} // end else if
bt1.onPress = function ()
{
fotos.load("loja.xml");
};
bt2.onPress = function ()
{
fotos.load("loja2.xml");
};
bt3.onPress = function ()
{
fotos.load("loja3.xml");
};
bt4.onPress = function ()
{
fotos.load("loja4.xml");
};
{
var _loc2 = container.attachMovie("item_mc", "i[" + coluna + "][" + linha + "]", container.getNextHighestDepth());
_loc2._x = Math.round(coluna * _loc2._width + coluna * 5);
_loc2._y = Math.round(linha * _loc2._height + linha * 5);
_loc2.url_fotop = dados[i].attributes.fotop;
_loc2.url_foto = dados[i].attributes.foto;
_loc2.nome.text = dados[i].attributes.nome;
_loc2.info = dados[i].attributes.desc;
_loc2.valor.text = dados[i].attributes.preco;
carregar.loadClip(dados[0].attributes.fotop, loader);
nome.text = dados[0].attributes.nome;
valor.text = dados[0].attributes.preco;
info.text = dados[0].attributes.desc;
_loc2.onRelease = function ()
{
carregar.loadClip(this.url_fotop, loader);
nome.text = this.nome.text;
valor.text = this.valor.text;
info.text = this.info;
};
mcs.push(_loc2);
carregar.loadClip(_loc2.url_fotop, _loc2.foto);
i++;
coluna++;
if (coluna >= qc && linha >= ql - 1)
{
return;
} // end if
if (coluna == qc && linha < ql)
{
coluna = 0;
++linha;
} // end if
if (i < len)
{
preencher(coluna, linha);
} // end if
} // End of the function
function removeAll()
{
var _loc1 = 0;
var _loc2 = mcs.length;
while (_loc1 < _loc2)
{
mcs[_loc1].removeMovieClip();
++_loc1;
} // end while
mcs = [];
} // End of the function
function ativar(num)
{
var i = 0;
while (i < qp)
{
if (num != i)
{
eval("paginacao.p" + i).enabled = true;
}
else
{
eval("paginacao.p" + i).enabled = false;
} // end else if
++i;
} // end while
} // End of the function
function criaPaginacao()
{
var _loc5 = qtd;
var _loc2 = 0;
var _loc4 = qp;
while (_loc2 < _loc4)
{
var _loc3 = paginacao.attachMovie("pag_mc", "p" + _loc2, paginacao.getNextHighestDepth());
_loc3._x = Math.round(_loc2 * _loc3._width + _loc2);
_loc3.idpag = _loc2 * (qc * ql);
_loc3.n_txt.text = _loc2 + 1;
_loc3.atual = _loc2;
_loc3.onRelease = function ()
{
removeAll();
ativar(this.atual);
i = this.idpag;
coluna = 0;
linha = 0;
preencher();
};
++_loc2;
} // end while
paginacao.p0.onRelease();
} // End of the function
var i = 0;
var coluna = 0;
var linha = 0;
var len = 0;
var dados;
var carregar = new MovieClipLoader();
var fotos = new XML();
var qc = 4;
var ql = 2;
var qp = 0;
var mcs = [];
fotos.ignoreWhite = true;
fotos.load("loja.xml");
fotos.onLoad = function ()
{
if (fotos.loaded == true)
{
dados = this.firstChild.childNodes;
len = dados.length;
qp = Math.ceil(len / (qc * ql));
if (qp > 1)
{
criaPaginacao();
delete prencher();
}
else if (qp <= 1)
{
preencher();
delete criaPaginacao();
paginacao.unloadMovie();
} // end if
} // end else if
};
stop ();
my_dg.setStyle("alternatingRowColors", [16777215, 16250871]);
my_dg.setStyle("borderStyle", "solid");
var myDP_array = new Array();
var conta = new Number();
var numero = new Number();
my_dg.resizableColumns = false;
my_dg.sortableColumns = false;
deleta.enabled = false;
fim.enabled = false;
my_dg.onLoad = function ()
{
myDP_array.push({Produto: algo, Qtd: algo, Preço: algo});
my_dg.dataProvider = myDP_array;
var _loc1 = my_dg.getColumnAt(0);
_loc1.width = 140;
my_dg.removeAll();
};
botao.onPress = function ()
{
fim.enabled = true;
var _loc2 = Number(my_nstep.value * valor.text);
myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
my_dg.dataProvider = myDP_array;
var _loc1 = Number(soma.text) + _loc2;
soma.text = _loc1;
total.text = _loc1;
numero = numero + 1;
};
fim.onPress = function ()
{
bt1.enabled = false;
bt2.enabled = false;
bt3.enabled = false;
bt4.enabled = false;
botao.enabled = false;
fim.enabled = false;
my_nstep.enabled = false;
check._visible = true;
produtos._visible = false;
container.unloadMovie();
paginacao.unloadMovie();
};
myGridListener = new Object();
myGridListener.change = function (eventObj)
{
deleta.enabled = true;
var eventSource = Number(my_dg.selectedItem.Preço);
deleta.onPress = function ()
{
if (my_dg.selectedIndex != undefined)
{
my_dg.removeItemAt(my_dg.selectedIndex);
var _loc2 = Number(eventSource);
var _loc1 = total.text - eventSource;
total.text = _loc1;
deleta.enabled = false;
numero = numero - 1;
if (numero == 0)
{
fim.enabled = false;
} // end if
} // end if
};
};
my_dg.addEventListener("change", myGridListener);
if (numero == 0)
{
deleta.enabled = false;
}
else
{
deleta.enabled = true;
} // end else if
bt1.onPress = function ()
{
fotos.load("loja.xml");
};
bt2.onPress = function ()
{
fotos.load("loja2.xml");
};
bt3.onPress = function ()
{
fotos.load("loja3.xml");
};
bt4.onPress = function ()
{
fotos.load("loja4.xml");
};
- function preencher()
- {
- var _loc2 = container.attachMovie("item_mc", "i[" + coluna + "][" + linha + "]", container.getNextHighestDepth());
- _loc2._x = Math.round(coluna * _loc2._width + coluna * 5);
- _loc2._y = Math.round(linha * _loc2._height + linha * 5);
- _loc2.url_fotop = dados[i].attributes.fotop;
- _loc2.url_foto = dados[i].attributes.foto;
- _loc2.nome.text = dados[i].attributes.nome;
- _loc2.info = dados[i].attributes.desc;
- _loc2.valor.text = dados[i].attributes.preco;
- carregar.loadClip(dados[0].attributes.fotop, loader);
- nome.text = dados[0].attributes.nome;
- valor.text = dados[0].attributes.preco;
- info.text = dados[0].attributes.desc;
- _loc2.onRelease = function ()
- {
- carregar.loadClip(this.url_fotop, loader);
- nome.text = this.nome.text;
- valor.text = this.valor.text;
- info.text = this.info;
- };
- mcs.push(_loc2);
- carregar.loadClip(_loc2.url_fotop, _loc2.foto);
- i++;
- coluna++;
- if (coluna >= qc && linha >= ql - 1)
- {
- return;
- } // end if
- if (coluna == qc && linha < ql)
- {
- coluna = 0;
- ++linha;
- } // end if
- if (i < len)
- {
- preencher(coluna, linha);
- } // end if
- } // End of the function
- function removeAll()
- {
- var _loc1 = 0;
- var _loc2 = mcs.length;
- while (_loc1 < _loc2)
- {
- mcs[_loc1].removeMovieClip();
- ++_loc1;
- } // end while
- mcs = [];
- } // End of the function
- function ativar(num)
- {
- var i = 0;
- while (i < qp)
- {
- if (num != i)
- {
- eval("paginacao.p" + i).enabled = true;
- }
- else
- {
- eval("paginacao.p" + i).enabled = false;
- } // end else if
- ++i;
- } // end while
- } // End of the function
- function criaPaginacao()
- {
- var _loc5 = qtd;
- var _loc2 = 0;
- var _loc4 = qp;
- while (_loc2 < _loc4)
- {
- var _loc3 = paginacao.attachMovie("pag_mc", "p" + _loc2, paginacao.getNextHighestDepth());
- _loc3._x = Math.round(_loc2 * _loc3._width + _loc2);
- _loc3.idpag = _loc2 * (qc * ql);
- _loc3.n_txt.text = _loc2 + 1;
- _loc3.atual = _loc2;
- _loc3.onRelease = function ()
- {
- removeAll();
- ativar(this.atual);
- i = this.idpag;
- coluna = 0;
- linha = 0;
- preencher();
- };
- ++_loc2;
- } // end while
- paginacao.p0.onRelease();
- } // End of the function
- var i = 0;
- var coluna = 0;
- var linha = 0;
- var len = 0;
- var dados;
- var carregar = new MovieClipLoader();
- var fotos = new XML();
- var qc = 4;
- var ql = 2;
- var qp = 0;
- var mcs = [];
- fotos.ignoreWhite = true;
- fotos.load("loja.xml");
- fotos.onLoad = function ()
- {
- if (fotos.loaded == true)
- {
- dados = this.firstChild.childNodes;
- len = dados.length;
- qp = Math.ceil(len / (qc * ql));
- if (qp > 1)
- {
- criaPaginacao();
- delete prencher();
- }
- else if (qp <= 1)
- {
- preencher();
- delete criaPaginacao();
- paginacao.unloadMovie();
- } // end if
- } // end else if
- };
- stop ();
- my_dg.setStyle("alternatingRowColors", [16777215, 16250871]);
- my_dg.setStyle("borderStyle", "solid");
- var myDP_array = new Array();
- var conta = new Number();
- var numero = new Number();
- my_dg.resizableColumns = false;
- my_dg.sortableColumns = false;
- deleta.enabled = false;
- fim.enabled = false;
- my_dg.onLoad = function ()
- {
- myDP_array.push({Produto: algo, Qtd: algo, Preço: algo});
- my_dg.dataProvider = myDP_array;
- var _loc1 = my_dg.getColumnAt(0);
- _loc1.width = 140;
- my_dg.removeAll();
- };
- botao.onPress = function ()
- {
- fim.enabled = true;
- var _loc2 = Number(my_nstep.value * valor.text);
- myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
- my_dg.dataProvider = myDP_array;
- var _loc1 = Number(soma.text) + _loc2;
- soma.text = _loc1;
- total.text = _loc1;
- numero = numero + 1;
- };
- fim.onPress = function ()
- {
- bt1.enabled = false;
- bt2.enabled = false;
- bt3.enabled = false;
- bt4.enabled = false;
- botao.enabled = false;
- fim.enabled = false;
- my_nstep.enabled = false;
- check._visible = true;
- produtos._visible = false;
- container.unloadMovie();
- paginacao.unloadMovie();
- };
- myGridListener = new Object();
- myGridListener.change = function (eventObj)
- {
- deleta.enabled = true;
- var eventSource = Number(my_dg.selectedItem.Preço);
- deleta.onPress = function ()
- {
- if (my_dg.selectedIndex != undefined)
- {
- my_dg.removeItemAt(my_dg.selectedIndex);
- var _loc2 = Number(eventSource);
- var _loc1 = total.text - eventSource;
- total.text = _loc1;
- deleta.enabled = false;
- numero = numero - 1;
- if (numero == 0)
- {
- fim.enabled = false;
- } // end if
- } // end if
- };
- };
- my_dg.addEventListener("change", myGridListener);
- if (numero == 0)
- {
- deleta.enabled = false;
- }
- else
- {
- deleta.enabled = true;
- } // end else if
- bt1.onPress = function ()
- {
- fotos.load("loja.xml");
- };
- bt2.onPress = function ()
- {
- fotos.load("loja2.xml");
- };
- bt3.onPress = function ()
- {
- fotos.load("loja3.xml");
- };
- bt4.onPress = function ()
- {
- fotos.load("loja4.xml");
- };
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
December 10th, 2008, 6:26 am
- rmarin
- Newbie


- Joined: Dec 10, 2008
- Posts: 5
- Status: Offline
- ATNO/TW
- Super Moderator


- Joined: May 28, 2003
- Posts: 23407
- Loc: Woodbridge VA
- Status: Offline
- rmarin
- Newbie


- Joined: Dec 10, 2008
- Posts: 5
- Status: Offline
- ATNO/TW
- Super Moderator


- Joined: May 28, 2003
- Posts: 23407
- Loc: Woodbridge VA
- Status: Offline
Well, NaN is obviously "not a number" and it's always going to come up when a variable is wrong - usually when it's not declared. It's hard for me because I looked at it fast and not sure exactly where all your variables are being defined etc. You would know that better than anyone, but you're getting the NaN because a variable is screwed up.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 5 posts
- Users browsing this forum: No registered users and 35 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
