To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > Flash Help > Flash MX

Reply
 
Thread Tools Search this Thread Display Modes
Old 03-27-2005, 02:06 AM   #1
RNFlasher
Member
 
Join Date: Aug 2001
Posts: 49
Dynamic Text - Can you display $ and , symbols when manipulating numbers?

I'd like to display a number like $35,000 in dynamic text, and subsequently subtract from that number. Can you do this?
RNFlasher is offline   Reply With Quote
Old 11-04-2009, 01:42 PM   #2
biornzhen
Junior Member
 
Join Date: Feb 2009
Posts: 4
did you figure it out? i have the same problem
biornzhen is offline   Reply With Quote
Old 11-04-2009, 02:36 PM   #3
a_modified_dog
FK'n_Mod
 
a_modified_dog's Avatar
 
Join Date: Apr 2003
Location: "aaarf"
Posts: 9,175
currency formatting

first - remove the "$" and "," using the string.split method
next - do the subtraction
last - pass the result through a currency formatting function

in this example the initial amount "$35,000" and the sum
to be subtracted - 4000 - are hardcoded - str1 & num1

PHP Code:
function stripChars(str:String){
str = str.split("$").join("");
str = str.split(",").join("");
return
str;
};

function
currFormat(nValue){
sResult = "";
var
nRound = Math.pow(10, 2);
nValue = Math.round(nValue*nRound);
var
sValDec = (2>0) ? "."+String(nValue).substr(String(nValue).length-2) : "";
var
sValInt = String(nValue).substr(0, String(nValue).length-2);
sValue = String(parseFloat(nValue));
var
sValIntLen = sValInt.length;
nTriple = Math.floor((sValIntLen-1)/3);
nRemainder = ((sValIntLen-1)%3)+1;
for(var
count=0; count<nTriple; count++) {
sResult = ","+sValInt.substr((sValIntLen-(3*(count+1))), 3)+sResult;
}
if(
nRemainder){ sResult = sValInt.substr(0, nRemainder)+sResult; }
if(
nPlaces && sValDec.length){
sResult = (sResult == "") ? "0" : sResult;
sResult += sValDec;
}
return
"$"+sResult;
};


str1 = "$35,000";
num1 = 4000;

Result = stripChars(str1)-num1;

output = currFormat(Result);
trace(output);
__________________
A Modified Domain .. [Flash 8][AS2] - [mySQL]
a_modified_dog is offline   Reply With Quote
Old 11-04-2009, 02:45 PM   #4
biornzhen
Junior Member
 
Join Date: Feb 2009
Posts: 4
great!! thanks!!!!!!!!!!!!!!!!!!!!!!!!

so, what if i just need the part of:
"pass the result through a currency formatting function"

which part of the code will help me?
This:

var sValIntLen = sValInt.length;
nTriple = Math.floor((sValIntLen-1)/3);
nRemainder = ((sValIntLen-1)%3)+1;
for(var count=0; count<nTriple; count++) {
sResult = ","+sValInt.substr((sValIntLen-(3*(count+1))), 3)+sResult;
}
if(nRemainder){ sResult = sValInt.substr(0, nRemainder)+sResult; }
if(nPlaces && sValDec.length){
sResult = (sResult == "") ? "0" : sResult;
sResult += sValDec;
}
return "$"+sResult;
};


????


thank you very much i really appreciate it.
biornzhen is offline   Reply With Quote
Old 11-04-2009, 03:09 PM   #5
a_modified_dog
FK'n_Mod
 
a_modified_dog's Avatar
 
Join Date: Apr 2003
Location: "aaarf"
Posts: 9,175
PHP Code:
function currFormat(nValue){

// you need all of
// the code posted above

return "$"+sResult;
};

output = currFormat(35000);
trace(output);
__________________
A Modified Domain .. [Flash 8][AS2] - [mySQL]
a_modified_dog is offline   Reply With Quote
Old 11-04-2009, 03:24 PM   #6
biornzhen
Junior Member
 
Join Date: Feb 2009
Posts: 4
thank you!!!!! i will try it
biornzhen is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > Flash Help > Flash MX

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:37 AM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.