Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 11-14-2009, 04:51 PM   #1
Join Date: Nov 2009
Posts: 70
Red face Adding textbox values together

Hello all, I am kind of a newcomer to Flash so this might seem like a silly problem.

There are 5 "price" textboxes on a particular frame. On a separate frame someone chooses an item and it populates those textboxes. What I want to do is be able to add together all of the "price" textboxes to populate the "total" textbox. I have tried parsing each textbox as an integer and then making a function to find the total and populate the "total" textbox but this just isn't working. It still has the value of 0 when I export. If I try parsing as a number it gives me a NaN value.

Any Suggestions?
goose756 is offline   Reply With Quote
Old 11-14-2009, 08:25 PM   #2
Registered User
Join Date: Nov 2009
Posts: 24

it would be better if you upload source file
TucoRamirez is offline   Reply With Quote
Old 11-14-2009, 08:36 PM   #3
Senior Member
Join Date: Nov 2009
Location: Lichfield, England
Posts: 284

If the prices are decimals, I don't think you can convert them to integers, which are whole numbers, eg 1, 12, 36, etc. To convert decimal strings, I think you need to convert them to Numbers.
julianboolean is offline   Reply With Quote
Old 11-14-2009, 09:04 PM   #4
Senior Member
Join Date: Mar 2009
Posts: 141

Have you tried casting the values?

ActionScript Code:
var totalValue:Number; totalValue= Number(myTextBox1.text) totalValue+= Number(myTextBox2.text) totalValue+= Number(myTextBox3.text) etc, etc
nicolanicola is offline   Reply With Quote
Old 11-14-2009, 10:47 PM   #5
Join Date: Oct 2005
Posts: 794

or you could extent the textbox class and add a proprty like numText that returns te text cast as a number
box86rowh is offline   Reply With Quote
Old 11-15-2009, 09:41 AM   #6
Senior Member
henke37's Avatar
Join Date: Mar 2009
Location: Sweden
Posts: 10,886
Send a message via Skype™ to henke37

You need to use parseInt or parseFloat, and you need to make sure that it is the plaintext that you are working with and not the htmlized version.
henke37 is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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. The time now is 11:41 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.