ActionScript 3.0 :: Get Only The Integer Part Of A Number ?
Feb 18, 2009How can I get only the integer part of a Number ?
3,14125 -> 3
How can I get only the integer part of a Number ?
3,14125 -> 3
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 $ ?
I've got a .txt file hosted on a freewebs, which my actionscript gets some variables for (for easy updating of statistics).
I want to do be able to do math in actionscript with these numbers I'm calling up from the .txt file, but the problem is that when I call up the variables, they are recognized as a string, instead of integers.
How would I convert the string to an integer in actionscript, or write the number in the .txt so that it's recognized as an integer.
I want to have a dynamic integer reference.
For instance
ActionScript Code:
var heart:int = 5;
var stalker:int = heart;
[Code].....
Obviously stalker traces as "5" while "heart" is "7". However, I need to make stalker a pointer reference to heart.
when I try to type cast something, there r 2 ways to do it:if var integer holds a integer (Uint)
text_txt.text = integer as String;or text_txt.text = String( integer );
but sometimes when I want to pass a value to a function both ways don't work and only one way works, when should I use option 1 and 2???
I want to get decimal part of the number in this case 67 (number = 67 ) First problem is internal calculations
ActionScript Code:
var number:Number = 987123456.67;
var intNum:Number = Math.floor(number);
var decimal = parseFloat(String(number - intNum));
trace(decimal); //outputs 0.6699999570846558, instead of 0.67
I wonder is there a any way to doit besides using toString?
Ok perhaps ive bitten off too much here...I know you are not supposed to parse xml/html to regex but the thing is there just arent many other options.Im using AS3.im parsing the source of textflowlayout text to a different format.
string to parse :
< fontFamily=Verdana encoding=unicode fontWeight="bold"> some text < fontFamily=Verdana encoding=unicode > some text < fontFamily=Arial encoding=unicode fontStyle="italic"> some text < fontFamily=Arial encoding=unicode fontWeight="bold" fontStyle="italic"> some text
what i really need is:
< fontname=Verdanabold encoding=unicode> some text < fontname=Verdana encoding=unicode > some text < fontname=Arialitalic encoding=unicode > some text < fontname=Arialbolditalic encoding=unicode > some text
logically i think of it as taking apart the string into substrings
checking if there are fontWeight or fontStyle in the substring
if there is then appending the font name with the weight or style so so that the font name becomes font NameWeightStyle.then rebuilding the string.The font could be any font with variouse styles or weights..so far:
pattern = /<(.*?)>/gixsm;
var matches:Object = pattern.exec(str);
var finalstring:String = "";[code]...........
I'am looking for a flv/video player which allow to seek for not loaded part of the video,just like on youtube.
View 1 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 RepliesThis is just a simple problem, i have two integers (for example)
var myInt:int = 3357;
var myOtherInt:int = 10;
Then i ask flash to trace myInt divided by myOtherInt
trace(myInt / myOtherInt);
And in the output menu i get 335.7 as the traced number and i need to get an integer which would be 335.
I'm working on a game were your health variable will add 1 hp automatically every second if the health variable is not equal to 100. How would you do that?
View 1 RepliesSomehow I cannot get the value of an integer inside a for-loop.
I define the vars like this:
ActionScript Code:
public class Fig2 {
private var a1_m1:int;
[Code].....
This gives me a: "1067: Implicit coercion of a value of type Array to an unrelated type int."
Is there a simple way to test whether an integer is odd or even withing a conditional statement? Example:
ActionScript Code:
if (integer /*insert code that checks for odd or even*/){
/*execute whatever*/
};
I've just seen a statement like this.
Code:
if (_root.map._width>"3000") {
_root.map.larger = 0;
}
Why 3000 put in quotes. Does it consider as a string on this expression?
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,
View 4 RepliesI try to increment each 2 hours but I don't know how to proceed.
View 2 RepliesI'm having some trouble converting a string to an integer. Here is my code:
var str:String = e.currentTarget.name as String; // Getting values like "song1", "song2"
str = str.replace("song", ""); // Changes it from "song1" or "song2" to "1" or "2"
var num:int = str as int; // SHOULD be converting the "1" to 1 and "2" to 2
trace("num:" + num + ", str:" + str);
The trace is always outputting:
num:0, str:1
num:0, str:2
etc..
The str value is there, but when it gets put into num then it zeros out.
I have 40 movieclips, with the instance names p[1-40] (for example, p14 or p32). I want them all to do something in order, so I'm using a 'for' loop. In simplified psuedo-code, it looks like:
for 40 {
variable = variable + 1
p[variable]
[code].....
I was trying to display a number: 2893604342.00. But, when i am displaying it it is displayed as: -2893604342.
Following is the code snippet ...
avg += int(totalData[i][col.dataField]);
I have even replaced it with Number, but it's still showing the same negative number.
How do I convert an integer to a string value? This must be easy. "Ya guys in SO are da best at explaining." I'm still working on these dumb counters.
NEED TO JOIN THIS TOGETHER
//My counter project "sends to dynamic text field"
var timer:Timer = new Timer(10);
var count:int = 0; //start at -1 if you want the first decimal to be 0
[Code]....
How do I remake my swf for xml commands? "Remake" sounds silly, but I just want to have integer values updated by an XML file. This may be beyond my understanding. I'd like an example, a mash-up, or method I can work from.
myThoughts
- It needs to read XML "parse it etc"
- variables receive e:data instead "my struggle with passing values and function calls"
XML
//XML
<head>
<seq_no>text</seq_no>
</head>
[Code]....
How do I extract the numbers out of a string like this[code]...
Everything but the currency symbol. Or from something like this:
rofl1.50lmao
Just asking if there's an existing function that I'm not a aware of.
The largest integer type in ActionScript seems to be a 32 bit uint (Representing values from 0 to 4294967295).I need something larger... ideally a 64 bit uint allowing values from 0 to 18446744073709551615.I was thinking of writing a class to represent these large numbers. I know there are classes for other languages (like bigint for perl) that can take care of this.
View 2 RepliesI seem to remember in an older version of Flash you could have a text field as an integer (whole number) and with a decimal point. Can someone please tell me how to do that in CS4?
View 0 RepliesI am trying to format a raw date input which is coming from an xml. Forexample: the input data is coming like date: 20090602. I wanna make it year:2009 month: 06 day: 02. I could only think 1 way to do it: by taking out the certain digits and assign them to seperate variables, or just 1 date variable. how to seperate certain digits?
View 2 RepliesI'm doing a calculator and making space between every third number, ie make 1000000 look like 1 000 000. It has to work dynamically, so if the result is 10000 it should show 10 000.
I'm doing a flash 5 movie.
how can I check if a variable is integer or not?
View 9 RepliesI need to add values in a string (they're strings because I get a date as timestamp from a database and then pluck it apart in Flash with substring). Flash doesn't do math with strings. So is there a way to cast the string into an integer value?
View 4 RepliesIs there a way to take all the letters out of a string and then use it as a integer?If that is not possible, is there a way to take the first three letters off a string variable? i.e. make myVariable='pic1' into myVariable = '1' Yes? no?
View 4 Replieshow can I check if a variable is integer or not?
View 5 Replies