Flash Store (sólo un problem.Suming valores), por favor ayuda

  • rmarin
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Dic 10, 2008
  • Mensajes: 5
  • Status: Offline

Nota Diciembre 10th, 2008, 6:26 am

Hola a todos
google para mi problema me acaban aquí y me di cuenta rápidamente este es un gran lugar y tantas cosas que ayudaron a resolver todos los...Espero poder ayudar también...

tengo una tienda de flash que se carga de xmls ..
todo está funcionando bien, pero no puedo resolver la suma / eliminación de los campos (los productos)

devuelve NaN de error
o sólo el producto que se añade última

my_nstep. valor es un menú desplegable donde elegimos Cant.
valor.text es el precio en la descripción del producto
myDP_array creats el producto, Quant, y el precio


la suma está aquí:
Código: [ 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. };




Este es el código completo si ayuda a
Código: [ 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
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Diciembre 10th, 2008, 6:26 am

  • rmarin
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Dic 10, 2008
  • Mensajes: 5
  • Status: Offline

Nota Diciembre 10th, 2008, 5:30 pm

nadie?
im atascado en esta justa
por favor ayuda
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • Avatar de Usuario
  • Registrado: May 28, 2003
  • Mensajes: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Nota Diciembre 10th, 2008, 6:49 pm

Me miró, pero no puede in situ el problema.
"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.
  • rmarin
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Dic 10, 2008
  • Mensajes: 5
  • Status: Offline

Nota Diciembre 10th, 2008, 7:36 pm

ATNO/TW escribió:
Me miró, pero no puede in situ el problema.


parece que todo está bien ¿no?

No tengo ningún compilador de errores...acaba de conseguir mantener la NaN...

gracias por la respuesta
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • Avatar de Usuario
  • Registrado: May 28, 2003
  • Mensajes: 23403
  • Loc: Woodbridge VA
  • Status: Offline

Nota Diciembre 10th, 2008, 7:56 pm

Bueno, NaN es, obviamente, "no es un número" y su siempre va a venir cuando una variable es un error - por lo general cuando su no declarado. Su duro para mí porque me miró rápidamente y no está seguro exactamente donde todas las variables se están definiendo etc Usted sabe mejor que nadie, pero que está recibiendo el NaN porque es una variable de follar.
"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.

Publicar Información

  • Total de mensajes en este tema: 5 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 50 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC