ActionScript 2.0 :: Getting Last Digit Of A Number?
Dec 9, 2005How do I isolate the last digit in a number. I.e. I have a variable called 'number' that is 24 and i want the 4 (The number never gets above 99)
View 5 RepliesHow do I isolate the last digit in a number. I.e. I have a variable called 'number' that is 24 and i want the 4 (The number never gets above 99)
View 5 Replieshow to specifically target the last digit all the way to the right of a number?For example, I have the numbers 113, 222, 1114, 318, 219 and I want to check if the last digit in the numbers equal 3, 4, 8, or 9.
View 7 Repliesi got an easy question that i couldn't find the answer to. what line of code do i need to use to change 123.456789 to 123.45.
code
oldNum = 123.456789;
newNum = ???
I want to have a text with digit size of about 300, but at a certain digit size, when i increase the digit size more, it will not increase in the swf file (even though it will increase as i intended in the .fla file).Is there a max digit size, and if so, can i increase it, and if not, why is this happening?the textfield is a dynamic textfield made in the .fla file (so not in as3).
View 2 RepliesI have this problem getting the numbers from a xml to flash because I only getting two-digit and hay need to get like 8 digit numbers and I dont know what happen.
Here is a example of the code:
var mybook:Number = 0;
var mymagazine:Number = 0;
var mycolor:Color = new Color(mccolor);
[Code]....
Is it possible to access a certain digit in a string? For example, if i currently had a value '321' then if i clicked on a button for example it changed the 2nd digit in the string to say 5...making it '352'.
This is probably really easy to do but im not sure how to do it!
Is there any way to force a two digit number with actionscript? Say, for instance, that I have a for loop that traces the numbers 1 through 9. In the output panel, I only get one digit numbers: 1, 2, 3,...9. Is there any way to make the trace output be 01, 02, 03,...09?
Obviously I could use an if statement to manually add zeros to all numbers that are less than 10, but is there a cleaner way to do it?
How do I find the digit sum of a floating point number?* (Eg Math.pow(10,100)). The correct answer would be 1. I have tried writing two functions, function A does not work for floating point numbers due to it converting numbers to strings, function B does not work for Math.pow(10,100) and other floating point numbers).
Specially: (1 with X zeros) % 10 = not 0, according to flash.
*Alternatively, what method can I use that gives me the last digit of a floating point number, and works for 1 with some number of zeros?
My functions:
private function getDSum(input:Number):Number {
var res:Number = 0;
for(var i = 0; i < input.toString().length+1; i++){
[Code]....
I use:
var gameScoreField:TextField = new TextField();
var gameScore:uint = 0;
gameScoreField.text = "Score: " + gameScore ;
[Code].....
If i use var gameScore:uint = 0000; the result will still return one 0, what can i do to make it 0000 instead?
I defined an array construct and assigned two variables to part of the array so I can simple sort it:
number1 = array[i]
number2 = array[i+1]
if(number1 > number2){
...swap etc
Problem is, when I try the comparason if the one of the numbers has a higher digit value, it ignores the statement entirely. Eg If 16 > 8 it skips it. So I tried adding '16' and '08' into the array and that worked perfectly with the statement.
what type of color is 16777215? and how can i convert it to 6 digit color?
View 4 RepliesDear Guys I Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It , Is There Any Solution
View 5 RepliesI Want To Generate A Random Number Between 2 Number BUT Without Generating 2 Same Number I Mean If For Example Already Generated Number "2" Next Time Did Not Generate It,
View 4 RepliesInside my code i have some variables declared as Numbers, and i get some others from an external source; these variables can either be Numbers or String representation of Numbers. Now, i have to implement some equality controls on these variables, and since i don't know in that moment which type are them of, i'm converting all of them to Numbers (i don't need and neither want to compare strings) via the Number() function which accepts either Numbers or Strings as an input. These controls can compare 2 single variables or a variable and a sum (or subtraction) of other variables, for example:
[Code]....
I'm trying to create a shuffle button for my mp3 player. I don't want it to repeat any song in the xml playlist until all the songs are played. Is there to display a random number on the click of a button, without repeating any number in the array until all the numbers in the array are used?
View 9 Repliesmy functions in this fla i have. I use the function to create a random number and the char move accordingly depending on the number.
View 4 RepliesSO, I want to do a very simple program, and I have no clue how to even get started. This is what I need to do. Several Different boxes to put something into. I Have Done That, I can type into them. Their instance names are
Box1
Box2
Box3
Heres what I have no clue on how to do though, completely lost. Box 1 needs to have the value psr.
[Code]...
I would like to know is there any limitations in flash textarea like the number of lines it can have or the number of bytes it can have. iam opening a text file using php in textarea, where all the contents of the files are not getting loaded in the textarea. If it is there then how to increase its size, is it same thing in flex?
View 1 Repliesexplain this...
var i:Number = 7059467160524343000;
trace(i);
i = 7059467160524343700;
trace(i);
i = 7059467160524343999;
[Code]...
I need to be able to round a given number to an even number that is divisible by 10, 100, or 1000 depending on it's size.
For example:
4 would be 0 -- Round to nearest 10
6 would be 10 -- Round to nearest 10
54 would be 50 -- Round to nearest 10
[code]....
I've been scanning the WWW for a formula to do this in as3, but have come up empty handed.
ActionScript Code:
var numbers:Array = [];
var newNb:Number;
var max:Number = 81;
[code]...
lets say that when you click on a button the variable number goes up 1 or 2 but it picks it randomly
how would i do it
[Code]...
i want to make random number between 1 to 10 without repeat number twice or more i use this function to make random
function getRandomNumber(min:Number, max:Number):Number
{
var randomNumber:Number = Math.round(Math.random() * (max - min) + min);
return randomNumber;
}
getRandomNumber(1, 10);
If I take a swf, and run it through swfdump
swfdump.exe -abc file.swf > ABC.txt
One the first run I may get some output in ABC.txt like this
ObjectConfig.as$60
And on a subsequent run of the same SWF get a different output
ObjectConfig.as$61
What is the meaning of the number after the $ ?
how to genrate serial number for datagrid according to the number of rows?
View 1 RepliesI have a problem with this code :
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"[code].....
I get the right number when I click on only '+' or only on '-'But if I click '-' until 0.7 and '+', it stays at 0.7
The same append when I click '-' until 0.9 when '+', it stay to 0.8. Why? How can I do to increment or decrement a Number by 0.1?
i got a input text , how do i set some number if they input the right one?like i want (2,4,6,8,10) to be true if they input the the same number ,i want boolean to be true how i going to do this?
View 2 Repliesthere is any method to check if a number is a decimal number or not? i searched in the help-panel, but didn't found something.
View 6 Replieshow can i convert a string ending in a number to a number? lets say i have a string such as somestring3 how can i convert that to a number 3?
View 7 RepliesI have been trying to find some code that lets me round a number to the nearest multiple of another number.So if for example we have number 44 the nearest multiple of seven would be 42.
View 1 Replies