ActionScript 3.0 :: Formatting The Numeric Field?
Oct 10, 2009I had been figuring out a way, in vain, formatting a numeric field, as we do in many other programming or scripting languages, like Format(number, "0000.00").
View 3 RepliesI had been figuring out a way, in vain, formatting a numeric field, as we do in many other programming or scripting languages, like Format(number, "0000.00").
View 3 RepliesI'm trying to use the flash numeric stepper component to pass it's current value into a dynamic text field using AS2.
So basically I drag the numeric stepper onto the stage. Next to it I place a dynamic text field with an instance name of myText.
So what I want is if I click the numeric stepper up to 3, then the dynamic text field will also say 3. Click the numeric stepper up to 22, then the dynamic text field will also say 22.
Can someone tell me the actionscript needed to do this and if the actionscript needs to go on the component itself or in the timeline.
I would like to input a numerical value into a dynamic text field using a button. The numerical values is one, the button is called a1_btn The dynamic input text field is called results_txt This is the code I am using. Even though it shows no script errors, clicking on the button doesn't input the number on the dynamic text field.
//Mouse event code
a1_btn.addEventListener(MouseEvent.CLICK, onClick);
//this is the value of the number
var number1:Number = 1;
[code]....
I have an input text field that is named in the properties box as 'numberOfKids'. When the program is executed, and a delete or backspace is pressed the input textfield goes blank and any calculations that use 'numberOfKids' shows NaN.I have trapped the NaN and undefined so that a numeric 0 shows up instead of a blank.
First problem: The cursor is to the left of the zero, so the first number inputted by the user is 10x larger than what they want. 0 becomes 10. How do I get the cursor to move to the right of the 0?
Second Problem: When I manually move the cursor to the right of the 0 and input a number, say 4, it shows up as 04. How do I delete the leading numeric zero in the input textfield?
Here's the code I am using:
calculateChildWeight = function () { if (isNaN(numberOfKids)) { numberOfKids = 0; } if ((numberOfKids) == undefined) { numberOfKids = 0; } if (numberOfKids>=0 && numberOfKids<=137) { numberOfKids = numberOfKids; } else { numberOfKids = 0; } if (isNaN(adjustedChildWeight)) { adjustedChildWeight = 0; } if ((adjustedChildWeight)=undefined) { adjustedChildWeight = 0; } adjustedChildWeight = Number(numberOfKids*(-100)); //numberOfKids.setSelection(numberOfKids.length, numberOfKids.length); //if (numberOfKids.length=2 && numberOfKids<10) { // remove the first character or leading zero// numberOfKids = numberOfKids;// }};
how to create formatted dynamic text fields, to embedding media in dynamic text fields without coding..in some graphical environment?In Flash authoring environment it is pain to do the formatting.[URL]
View 2 RepliesI've got an external xml file loaded into a text field... I'm trying to format the text within the xml file with actionscript. Specifically, I'd like to make the dates a different color from the actual posts, and I want to add a blank line between each post. Here's the xml file:
Code:
<?xml version="1.0" encoding="utf-8"?>
<news>
<post>
<date>01.07.11</date>
<content>A lot has changed for the band. For one, we are no longer Tracey Bones. Now we are called Sinister Kid. Also, the band's added a new member to its ranks -- me, Andres, on vocals, which leaves Tyler able to concetrate completely on guitar. And I brought this website with me. It's not much in terms of content, but I figured I'd get a little creative with the animation, so enjoy.
</content>
</post>
<post>
<date>01.07.11</date>
[code]....
I'm currently using a datefield compinent to assess a window for customers to have work done. Problem is, automatic e-mails generated by my ASP server page look a little bit shoddy when they are received because of the long format of the selectdate variable return:Mon Feb 7 00:00:00 GMT+0000 2005Is there an easy way to perform this formatting or would i need to use a string function to substring the field?
View 5 RepliesI'm loading data from an XML file with html specific tags so I can put all the formatting of the text field in the XML file, my XML looks something like this:
[Code]...
i want to parse the web html to flex text field
to use string function splice etc. to replace tags with the one which text fields can understand but is it too complex and processing over head is there that reduces the efficiency but i have max control to do changes what i needed. parsing the html to xml and then use this as the text input to text field what about the efficiency and control need to know about from this question. regular expressions .
If you're creating a htmlText field via the createTextField method, is there a way to get html formatting like <b></b> to show up if you are also embedding a font? I'm guessing not, since you can only embed a single font in a TextFormat, and you would have to embed both italic and bold variants too to make it work. Is this true?Maybe I'm better off creating a generic text field on the stage with both bold and italics embedded, and use the attachMovie method instead?This is my code:
ActionScript Code:
myformat = new TextFormat();
myformat.font = "Akzidenz_Grotesk_BE_Light";
[code].....
I make RSS reader in flash. I have a text field and when I place RSS text and images in that text field I need to have a text in the new line after picture. But now I have image from the left and text from the right.
View 1 RepliesI'm building this flash site for a friend and he wants to be able to edit the contents and maintain the site by himself later on. So naturally, I used a dynamic text field that uses URLloader to link to an external html, dandy. Problem is, my friend wants to use dreamweaver to edit the contents of html (or even just a word document exported as html) and it's just driving him nuts because the text look nothing like that way it did in DW when it's loaded into the dynamic text field (extra spacing and line break popping up randomly everywhere). Is there an alternative solution other then telling him to just edit it in notepad? What if I switch over to XML?
View 2 Repliesmake one word in a dynamic text field bold WITHOUT using the htmlText property? Everything I have read seems to indicate that you can only make the whole field bold.
View 3 RepliesI make RSS reader in flash. I have a text field and when I place RSS text and images in that text field I need to have a text in the new line after picture. But now I have image from the left and text from the right.
View 2 RepliesIn one of my Action Script 3 projects I need to create package names having numerics in them. For example I am writing one of the package name as com.projectname.activity101.view.*
My query is whether it is okay to have numerics in the package name as in the above example. I am asking this query as once working with Flash 7 I had used the package name ending in number that gave me some issues. When I changed the package name to have only alphabets in it the issue was resolved.
I am importing a numeric value from an xml file. It shows correctly when I trace the loader, but when I trace the variable it is stored in I get "NaN" (Not a Number). Here is the code:I have created a variable with the data type number:[code]
View 7 RepliesWhat it is I am trying to achieve is 6 cards each with their own numeric value. (1, 2, 4, 8, 16, 32) when the card is clicked its values get added together and but remain invisible until the reveal button is pressed.
ActionScript Code:
c1_btn.addEventListener(MouseEvent.CLICK, c1Click);
c2_btn.addEventListener(MouseEvent.CLICK, c2Click);
c4_btn.addEventListener(MouseEvent.CLICK, c4Click);
c8_btn.addEventListener(MouseEvent.CLICK, c8Click);
c16_btn.addEventListener(MouseEvent.CLICK, c16Click);
c32_btn.addEventListener(MouseEvent.CLICK, c32Click);
reveal_btn.addEventListener(MouseEvent.CLICK, revClick);
[Code] .....
I tried to utilize a basic calculator script and tryed to modify it. This is probably the the 5th version iv made.
nTest = 1 //numeric
sTest = " test" //string
sFinal = nTest & sTest //string
I get an error with this, because sFinal is a string, and im tryin to put in an numeric value. How can I create this code so that it will work? I want the sFinal to contain "1 test". This code is useless, I know, but this is just an example.
I have a button on the screen with the the following code attached to it's release function.
[Code]...
No matter how i sort the dataTag array it never puts the information into the respective order. The 10XXX figures always come ahead of the preceeding numerals. Anyone come across this before who can point me in the right direction?
In my movie i have a shopping cart which adds up a total of all items. When the total reaches more the 1000.00 i need to add in a comma separator as in 1,000.00 if i do this manually flash no longer see's the variable as a number, how do i get around this one?
View 2 RepliesI am trying something where I have 2 Numeric Steppers. One numeric stepper holds values from 0-230 and the other from 0.00-0.99. My question is how to change the value of the first numeric stepper when the second numeric stepper goes from 0.99 to 0.00. Suppose the first numeric stepper has a value 10 and the second numeric stepper is being incremented continuously. As it reaches 0.99 and on mouse up on the up arrow, 10 should change to 11 and this numeric stepper goes to 0.00.
View 1 RepliesI am loading data from an xml file into several different arrays. Once its all information is in the arrays I then sort one of the arrays (called percentage) numerically from highest to lowest. What I can't figure out is how to reflect the changes in position in the other arrays to what has happened in the percentage array.
View 6 Repliesi have an array that i basically load from a csv file. i have a function below that test every number for the value if is a number.[code]the problem im having is that when it reads the array is reading ",15" instead off "15" how do i remove a character from an array ? i dont want to remove the whole element just a character.
View 9 RepliesI have an mc.instance name is Twentysecond it has a text box called label When clicked Twentysecond populates a text box and I want to use this code Flash will not let me use an instance name of 22nd.
TwentySecond.label = _name;//(I want this to show 22)
onRelease = function(){
myTextBox = _name; // (I want this to show 22nd
}
I should know how to do this, but memory is failing.
i'm doing a new mathematic fill in the blank quiz application and the details are as below.ample:When i type in any answer like 0015, 015, 15.0, 15.00 should be acceptable and absolute to 15. So, what should i do
View 3 RepliesI have a DataGrid in Flash 8 Professional. I am having trouble sorting numerical data. Here is the code placed on the frame (modified from the tutorial):
[Code]...
Is there a way to extract a numeric value from my variable using concatination.
var i:Number = 1;
var test1value:Number = 3;
trace(this["test"+i+"value"]);
I tried all kinds of tricks but I just can get the string name of the variable instead of the value it holds.
I started to mess up with classes to see how they work, and I'm having some troubleI'm trying to do a class where the user gives an array, and a number. The result is a trace of random X numbers, according to the number the user requested. If he/she types 3, the class gives 3 numbers.It works nice, but when I try to put an sort(Array.NUMERIC), i get this error:
PHP Code:
TypeError: Error #1034: Type Coercion failed: cannot convert undefined to Function. at Array$/_sort() at
[code]....
I have a Flex UI and want the numeric stepper to add a preceeding '0' to the displayed value if it's between 0 and 9, so that it's always 2 digits.
View 1 Repliesi have numeric stepper in MXML component.when i entered manually numeric value and press a button to add the current value in my datagrid column row.First time its not effected in datagrid column.But when i clicked second time value effected in my datagrird column.
How i can get manually entered value in datagrid column on first click of button.
protected function id_btnAdd_mouseDownHandler(event:MouseEvent):void
{
{
edlColor = new EDLColor();
edlColor.ColorToString = "rgb(0,0,0)";
[code]....