Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-11-2012, 08:36 PM   #1
rigelj
Registered User
 
Join Date: May 2012
Posts: 4
Default Input Text in Math

Is it possible to use input text in math equations?
rigelj is offline   Reply With Quote
Old 05-11-2012, 08:43 PM   #2
abeall
Senior Member
 
Join Date: Feb 2006
Location: Washington, DC
Posts: 2,717
Send a message via AIM to abeall
Default

Yes.

ActionScript Code:
var inputNum:Number = Number(myInputText.text); if(isNaN(inputNum)){     // user input invalid number! }else{     // do math as usual, ex:     inputNum * 2; }

You will probably want to set the input text restrict to just numbers, and dot if you want decimals.

If you want to parse out a full expression from input text, that's a much trickier subject.
__________________
Aaron Beall | Flash portfolio | Fireworks extensions | Twitter
abeall is offline   Reply With Quote
Reply


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 02:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, 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.