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

  • rmarin
  • Newbie
  • Newbie
  • rmarin
  • Posts: 5

Post 3+ Months Ago

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:
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;
};
  1. botao.onPress = function ()
  2. {
  3.     fim.enabled = true;
  4.     var _loc2 = Number(my_nstep.value * valor.text);
  5.     myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
  6.     my_dg.dataProvider = myDP_array;
  7.     var _loc1 = Number(soma.text) + _loc2;
  8.     soma.text = _loc1;
  9.     total.text = _loc1;
  10.     numero = numero + 1;
  11. };




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");
};
  1. function preencher()
  2. {
  3.     var _loc2 = container.attachMovie("item_mc", "i[" + coluna + "][" + linha + "]", container.getNextHighestDepth());
  4.     _loc2._x = Math.round(coluna * _loc2._width + coluna * 5);
  5.     _loc2._y = Math.round(linha * _loc2._height + linha * 5);
  6.     _loc2.url_fotop = dados[i].attributes.fotop;
  7.     _loc2.url_foto = dados[i].attributes.foto;
  8.     _loc2.nome.text = dados[i].attributes.nome;
  9.     _loc2.info = dados[i].attributes.desc;
  10.     _loc2.valor.text = dados[i].attributes.preco;
  11.     carregar.loadClip(dados[0].attributes.fotop, loader);
  12.     nome.text = dados[0].attributes.nome;
  13.     valor.text = dados[0].attributes.preco;
  14.     info.text = dados[0].attributes.desc;
  15.     _loc2.onRelease = function ()
  16.     {
  17.         carregar.loadClip(this.url_fotop, loader);
  18.         nome.text = this.nome.text;
  19.         valor.text = this.valor.text;
  20.         info.text = this.info;
  21.     };
  22.     mcs.push(_loc2);
  23.     carregar.loadClip(_loc2.url_fotop, _loc2.foto);
  24.     i++;
  25.     coluna++;
  26.     if (coluna >= qc && linha >= ql - 1)
  27.     {
  28.         return;
  29.     } // end if
  30.     if (coluna == qc && linha < ql)
  31.     {
  32.         coluna = 0;
  33.         ++linha;
  34.     } // end if
  35.     if (i < len)
  36.     {
  37.         preencher(coluna, linha);
  38.     } // end if
  39. } // End of the function
  40. function removeAll()
  41. {
  42.     var _loc1 = 0;
  43.     var _loc2 = mcs.length;
  44.     while (_loc1 < _loc2)
  45.     {
  46.         mcs[_loc1].removeMovieClip();
  47.         ++_loc1;
  48.     } // end while
  49.     mcs = [];
  50. } // End of the function
  51. function ativar(num)
  52. {
  53.     var i = 0;
  54.     while (i < qp)
  55.     {
  56.         if (num != i)
  57.         {
  58.             eval("paginacao.p" + i).enabled = true;
  59.         }
  60.         else
  61.         {
  62.             eval("paginacao.p" + i).enabled = false;
  63.         } // end else if
  64.         ++i;
  65.     } // end while
  66. } // End of the function
  67. function criaPaginacao()
  68. {
  69.     var _loc5 = qtd;
  70.     var _loc2 = 0;
  71.     var _loc4 = qp;
  72.     while (_loc2 < _loc4)
  73.     {
  74.         var _loc3 = paginacao.attachMovie("pag_mc", "p" + _loc2, paginacao.getNextHighestDepth());
  75.         _loc3._x = Math.round(_loc2 * _loc3._width + _loc2);
  76.         _loc3.idpag = _loc2 * (qc * ql);
  77.         _loc3.n_txt.text = _loc2 + 1;
  78.         _loc3.atual = _loc2;
  79.         _loc3.onRelease = function ()
  80.         {
  81.             removeAll();
  82.             ativar(this.atual);
  83.             i = this.idpag;
  84.             coluna = 0;
  85.             linha = 0;
  86.             preencher();
  87.         };
  88.         ++_loc2;
  89.     } // end while
  90.     paginacao.p0.onRelease();
  91. } // End of the function
  92. var i = 0;
  93. var coluna = 0;
  94. var linha = 0;
  95. var len = 0;
  96. var dados;
  97. var carregar = new MovieClipLoader();
  98. var fotos = new XML();
  99. var qc = 4;
  100. var ql = 2;
  101. var qp = 0;
  102. var mcs = [];
  103. fotos.ignoreWhite = true;
  104. fotos.load("loja.xml");
  105. fotos.onLoad = function ()
  106. {
  107.     if (fotos.loaded == true)
  108.     {
  109.         dados = this.firstChild.childNodes;
  110.         len = dados.length;
  111.         qp = Math.ceil(len / (qc * ql));
  112.         if (qp > 1)
  113.         {
  114.             criaPaginacao();
  115.             delete prencher();
  116.         }
  117.         else if (qp <= 1)
  118.         {
  119.             preencher();
  120.             delete criaPaginacao();
  121.             paginacao.unloadMovie();
  122.         } // end if
  123.     } // end else if
  124. };
  125. stop ();
  126. my_dg.setStyle("alternatingRowColors", [16777215, 16250871]);
  127. my_dg.setStyle("borderStyle", "solid");
  128. var myDP_array = new Array();
  129. var conta = new Number();
  130. var numero = new Number();
  131. my_dg.resizableColumns = false;
  132. my_dg.sortableColumns = false;
  133. deleta.enabled = false;
  134. fim.enabled = false;
  135. my_dg.onLoad = function ()
  136. {
  137.     myDP_array.push({Produto: algo, Qtd: algo, Preço: algo});
  138.     my_dg.dataProvider = myDP_array;
  139.     var _loc1 = my_dg.getColumnAt(0);
  140.     _loc1.width = 140;
  141.     my_dg.removeAll();
  142. };
  143. botao.onPress = function ()
  144. {
  145.     fim.enabled = true;
  146.     var _loc2 = Number(my_nstep.value * valor.text);
  147.     myDP_array.push({Produto: nome.text, Qtd: my_nstep.value, Preço: _loc2});
  148.     my_dg.dataProvider = myDP_array;
  149.     var _loc1 = Number(soma.text) + _loc2;
  150.     soma.text = _loc1;
  151.     total.text = _loc1;
  152.     numero = numero + 1;
  153. };
  154. fim.onPress = function ()
  155. {
  156.     bt1.enabled = false;
  157.     bt2.enabled = false;
  158.     bt3.enabled = false;
  159.     bt4.enabled = false;
  160.     botao.enabled = false;
  161.     fim.enabled = false;
  162.     my_nstep.enabled = false;
  163.     check._visible = true;
  164.     produtos._visible = false;
  165.     container.unloadMovie();
  166.     paginacao.unloadMovie();
  167. };
  168. myGridListener = new Object();
  169. myGridListener.change = function (eventObj)
  170. {
  171.     deleta.enabled = true;
  172.     var eventSource = Number(my_dg.selectedItem.Preço);
  173.     deleta.onPress = function ()
  174.     {
  175.         if (my_dg.selectedIndex != undefined)
  176.         {
  177.             my_dg.removeItemAt(my_dg.selectedIndex);
  178.             var _loc2 = Number(eventSource);
  179.             var _loc1 = total.text - eventSource;
  180.             total.text = _loc1;
  181.             deleta.enabled = false;
  182.             numero = numero - 1;
  183.             if (numero == 0)
  184.             {
  185.                 fim.enabled = false;
  186.             } // end if
  187.         } // end if
  188.     };
  189. };
  190. my_dg.addEventListener("change", myGridListener);
  191. if (numero == 0)
  192. {
  193.     deleta.enabled = false;
  194. }
  195. else
  196. {
  197.     deleta.enabled = true;
  198. } // end else if
  199. bt1.onPress = function ()
  200. {
  201.     fotos.load("loja.xml");
  202. };
  203. bt2.onPress = function ()
  204. {
  205.     fotos.load("loja2.xml");
  206. };
  207. bt3.onPress = function ()
  208. {
  209.     fotos.load("loja3.xml");
  210. };
  211. bt4.onPress = function ()
  212. {
  213.     fotos.load("loja4.xml");
  214. };
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • rmarin
  • Newbie
  • Newbie
  • rmarin
  • Posts: 5

Post 3+ Months Ago

no one??
im stuck in just this
please help
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

I looked at it but couldn't spot the problem.
  • rmarin
  • Newbie
  • Newbie
  • rmarin
  • Posts: 5

Post 3+ Months Ago

ATNO/TW wrote:
I looked at it but couldn't spot the problem.


it seems everything is ok right?

i have no compiler errors... just keep getting the NaN...

thanks for the reply
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 13 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.