Ciao a tutti,
devo formattare un prezzo da 10.000 a 10,00 in actionscript.
C'è qualcuno che conosce qualche script in merito?
Grazie
Ciao a tutti,
devo formattare un prezzo da 10.000 a 10,00 in actionscript.
C'è qualcuno che conosce qualche script in merito?
Grazie
Ciao.
Non c'è una funzione specifica a meno che non esista una qualche classe già pronta
Comunque non è difficile, io farei una roba del genere:
Codice PHP:var val:Number = 123.456;
var output:String = int(val)+','+Math.round(val*100).toString().substr(-2);
trace(output); // output: 123,46
Installa Forum HTML.it Toolset per una fruizione ottimale del Forum
Grazie per la risposta, ma come faccio a settare con il codice che mi hai mandato queste due variabili?
totalamount e attributes.price. (inserisco sotto il codice del carrello)
cartstatus = function() {
totalamount = 0;
totalshipping = 25;
totalitems = 0;
for (i=0; i<=selecteditems.length-1; i++) {
if (isNaN(selecteditems[i].attributes.shipping) == false) {
totalamount += (Number(selecteditems[i].attributes.price) * Number(selecteditems[i].attributes.quantity));
totalshipping += (Number(selecteditems[i].attributes.shipping) * Number(selecteditems[i].attributes.quantity));
} else {
totalamount += (Number(selecteditems[i].attributes.price) * Number(selecteditems[i].attributes.quantity));
}
totalitems += Number(selecteditems[i].attributes.quantity);
}
if (selecteditems.length == 0) {
btn.txt.text = "0 articoli";
} else {
if (totalshipping > 0) {
btn.txt.text = currencysymbol + String(totalamount -(totalamount/100)*8) + " + " + currencysymbol + String(totalshipping) + " = " + currencysymbol + String(totalamount + totalshipping) + " " + String(totalitems) + " articoli";
} else {
btn.txt.text = currencysymbol + String(totalamount) + " " + String(totalitems) + " articoli";
}
}
}
cartstatus();
showmessagewin = function() {
hidemovie(messagewin);
messagewin = attachMovie("messagewindow", "messagewin" + String(getNextHighestDepth()), getNextHighestDepth());
showmovie(messagewin);
tip.swapDepths(getNextHighestDepth());
}
Grazie ancora
Non ho idea di come funzioni quello script e non capisco quali valori debbano essere formattati.
Ad ogni modo io farei una funzioncina dello script che ti ho suggerito, in modo che possa essere richiamata da qualsiasi punto e, passando un dato valore, questo sia restituito formattato.
Una roba del genere:
codice:function formatta(val) { return int(val)+','+Math.round(val*100).toString().substr(-2); } var input = 123.456+78.9; trace("costo totale: "+formatta(input)); // output: "costo totale: costo totale: 202,36"
Vedi tu dove va inserita.
Installa Forum HTML.it Toolset per una fruizione ottimale del Forum
Ok ci provo.