Flex/mxml: How to display a Number in scientific notation in TextInput box? - actionscript-3

In my Flex application, I have a TextInput box that a user may enter a Number. It comes in as a String, then passes through a NumberFormatter. The result then gets displayed in the TextInput box. This works fine for small numbers.
Large numbers have a problem. For example, if the user enters 100e30 (which is scientific notation for 1x10^32), the TextInput displays:
100000000000000000000000000000000
when what I really want to display is
1.0E32
This is how it appears (and is stored) internally in Flash Builder, for example, as viewed using the debugger.
Is there any simple routine in AS3/mxml that can output scientific notation to a TextInput control?

var n:Number = 10000000000;
trace(n.toExponential(1));
Output :
1.0e+10
To set it to the text input :
textInput.text = n.toExponential(1);

Related

Putting code in a text box (MS Access)

I am using a textbox for the header of my report, and based on what the user selects it will be "Baseline 8", "Baseline 9", etc. What I would like to do is have the text box coded so whatever number the user selects is entered into the text box. I managed to do it by using two text boxes, one just says "baseline" and the other text box says "=[Forms]![Navigation Form]![NavigationSubform]![Combo21]" and it will enter the correct value. But what I want to do is put it all in one box, and when I put "Baseline =[Forms]![Navigation Form]![NavigationSubform]![Combo21]" in the text box it doesn't work, it just leaves the code as the header when I generate the report. Is there something I'm not doing correctly?
First of all, when you state that a "textbox says", you really mean that "the Control Source property of the textbox equals." For a textbox (and some other controls), the value that you see on the actual form IS the Control Source property. I am not being picky for its own sake, rather it is important to recognize what value you are editing.
The Control Source property can essentially contain two types of values. The first is without an equals sign and it indicates the name of a field from the form Record Source. In that case, it binds the control to the field directly so that it automatically loads from the field and saves changes back to the field.
The second type of value always starts with =. It is a VBA code expression and can include calls to functions and other VBA operators. In your case, you want to concatenate (i.e. combine) two strings: one literal "Baseline" and one pulled from an access object [Forms]![Navigation Form]![NavigationSubform]![Combo21], so you need to use the string concatenation operator &.
="Baseline " & [Forms]![Navigation Form]![NavigationSubform]![Combo21]

Auto insert area code

I have a text box in Microsoft Access 2013 that corresponds to a telephone number. The text box has the input mask of:
!\(999") "000\-0000;;_
I am trying to auto insert the area code. For example, when a users goes to enter a telephone number, the area code is already populated into the text box. I have tried to set the default value in both the table design and on the property sheet of the text box but no luck. Its always aligned to the right. For example it looks like this:
If I add spaces to the default value on the text box property, the input mask is ignored and Microsoft Access generates an error stating:
The value you entered isn't appropriate for the input mask '!(999") "000-0000;;_' specified for this field.
I have contemplated modifying the table structure to include a specific field for an area code, but that is my last resort.
Is there a more efficient way to automatically populate the area code in the text box when a new record is generated?
You can write a function in VBA to do this. Something like;
Function FormatPhone(PhoneNumber As String) As String
FormatPhone = "(719)" & PhoneNumber
End Function
This function will take a string like '123-4567' and return '(719)123-4567'.
In the AfterUpdate event of your phone number field put;
[TextBoxControlName].Value = FormatPhone(Nz([TextBoxControlName].Value,""))
and this will add the formatted string to the text box.

AS3/Air/Starling mobile app textinput class and how to get text value when in a class

I have a mobile app built in as3/air for mobile devices and I am wondering what the best approach to handle textinput fields are.
What I mean is I have multiple input fields on multiple screens. The inputs have a label (textfield), background color under the label (quad) and an input (textinput). Some are password, some are not. Some are different width/heights, multi-line/single line etc. All however use embedded fonts, have a name and ID assigned etc.
I have created a class file that extends Sprite and built all the components of the textinput (textfield, quad, textinput) so my other classes/screens can just create a new instance of this class passing custom values.
var textField:TextFieldClass = new TextFieldClass();
textField.DrawTextField(name, ID, width, height, isPassword, hasLabel, labelPosition etc);
The above works great. I can reuse the class to draw multiple textinput on screen with minimal code however I am having trouble getting the text value/ID/name when there are multiple instances.
I have tried adding each textField instance into an array and iterating through but that gets x number of the last textField instance e.g. if first instance is named txtEmail and the second is txtPassword, I get 2 txtPasswords.
I have also tried getChildByName and specifying the name of the textinput but when I use txtEmail I get a cannot access null value but txtPassword works.
Maybe I am going about this wrong so happy to use a better approach if one exists (which I am sure there is). Basically I would like to have a reusable textinput class that allows custom design (quads, fonts etc) without having to copy paste the entire textinput code for each new input field.
Thanks

Defining input text as a number input in Flash

So, when I'm building an application in Flash and Actionscript 3.0 I create a sharedobject.data and I have an input field, the sharedobject is equal to the input field.But it's only restricted to numbers, but when the input is put in the number is thought to be text.. rather than an actual number (eg. "1" instead of just 1) is there anyway that I can make an input field into something like a number field?
Have you tried:
var variable:Number;
variable= Number(input_txt.text);

How apply SSN masking over text input in Flash Builder 4?

i want to apply masking over the textinput that need to get SSN from user so How apply SSN masking over text input in Flash Builder 4?
The most elegant solution in the long run would be to create a custom component, but it could also be done within an existing TextInput. Give the TextInput a change event that does the following:
var s:String=textInput.text.replace(/[^0-9]/g,"");
textInput.text = s.substring(0,3) +
(s.length>3?"-"+s.substring(3,5)+
(s.length>5?"-"+s.substring(5,9):""):"");
textInput.selectRange(textInput.text.length,textInput.text.length);
This will mask the characters:
txtInput.displayAsPassword = true;
<s:TextInput displayAsPassword="true" restrict="0-9" maxChars="9"/> will cause the text to be shown as asterisks when the user is entering it, and will also prevent them from entering more than 9 characters, or any characters that are not numeric, both of which are requirements of SSNs.