Changing String To Number
Hi,
I need to change string to number but the problem is that string is a hex rgb value (0xAAFF13).
If you declare a var with 0xAAFF13 its value is something like 16777215.
I use it for RGB change. Available colors are stored in Array. I used "" for storing values in array because Actionscript gets confused if I try to push 0xAAFF13 without "".
Using Number returns NaN.
Any suggestions?
Thanks
Igor
FlashKit > Flash Help > Flash ActionScript
Posted on: 10-18-2001, 03:57 AM
View Complete Forum Thread with Replies
Sponsored Links:
[MX] Changing A Variable Contents From A Number To A String
I have a variable called total.
The value of total is a random dollar and cents amount.
When I display the contents of the variable on the screen, (in a dynamic string) there is no comma separator at the 1,000 mark. How do I make the number show the comma separator? (I already have the string set to "$ "+total+"" which results in (for example) $ 52435.25
Please Help!
Thanks in advance,
Brian
View Replies !
View Related
Help Can't Convert String To Number With Number()
I'm pulling variables from an XML file and need to convert the strings from the XML to numbers. So, I have the following actionscript:
Code:
thisPC_Price = aPrice[0].stringValue();
trace(thisPC_Price);
trace(Number(thisPC_Price));
The first trace returns 100, which is the contents of the string (it's also treated like a string by the AS and if I try and do anything to it it will return NaN, as it should). The 2nd trace action returns NaN ..... and I have no idea why.
Anyone have any ideas?
View Replies !
View Related
Changing A String Name In A Loop / Concatonating String Name?
Hey all,
Does anybody know of a way to change a string name as a loop proceeds?
This is the main piece of code that I wish to loop with i incrementing, so that whilst i=0 then:
_root.barARed._visible=barRed[i];
_root.barARed._width=barLength[i];
_root.barAYellow._visible=barYellow[i];
_root.barAYellow._width=barLength[i];
_root.barAGreen._visible=barGreen[i];
_root.barAGreen._width=barLength[i];
infoA.text=info[i];
and i=2 then:
_root.barBRed._visible=barRed[i];
_root.barBRed._width=barLength[i];
_root.barBYellow._visible=barYellow[i];
_root.barBYellow._width=barLength[i];
_root.barBGreen._visible=barGreen[i];
_root.barBGreen._width=barLength[i];
infoB.text=info[i];
and so on...I would use _root.barRedInstanceName[i]._visible=barRed[i]; but I can't give the movie clip (the bar) an instance name such as redBar[1], redBar[2] etc. (system reserved I'm told)
I guess what I am trying to ask in a roundabout way: is how do you concatonate the name, rather than the contents of a string?
Hope you'll forgive me if this is something really simple that I am overlooking, but I only have a very short experience of flash.
Thanks
Al
View Replies !
View Related
[F8] Number + Number = String?
Hi, I wonder if anyone can help me with this.
This code gives me the result 100100.
PHP Code:
var one:Number = 100;
var two:Number = 100;
var result:Number = one + two;
result then prints as 100100.
I don't understand why.
View Replies !
View Related
Number Or String
I am passing variables into flash through the param and embed tags (which use asp to get them from the URL query string)
When i pass in a variable named hole1=6, the 6 doesnt seem to be a number value. it acts like a string because when i perform functions on it (like + or -) this is the result:
6+5 = 65 instead of 6+5 = 11
any thoughts?
View Replies !
View Related
From String To Number
hi everyone:
from visual basic i send my swf a number formated like this, "100,000,00.56".
i use a dynamic text to show it, and i works fine.
the problem is that i need that number for another code (a graph), and it doesn't work because, i think, flash is taking it as a string, with the "," and ".".
so what i need is to format the string "100,000,00.56" into the corresponding number. and i need to do that in flash not visual basic.
help please.
thanks, take care.
View Replies !
View Related
Number To String?
Hi,
I have a number im trying to covert to a string so it can be displayed in a text field.
Can any one tell me how?
I have tryed.
holder = holder.toString();
but still get the same problem.
View Replies !
View Related
String To A Number
Hi All
So it looks as though my threshold idea is impossible. I have another idea though. Only one thing is holding me back. I need to convert a hex string to a number variable. I looked at parseInt but this appears to be a method of gaining a decimal number ie 0x44D391 would become 68208152 (I think). I need the variable to retain its original 0x.... so I can use it in the threshold method.
Cheers
Jim
View Replies !
View Related
String To Number
i am loading in a number from a text file. In the code below how can I change MyPercent to a Numberr variable so I can add it to other numbers?
// create a loadVars object to get the txt data
var myLoadVars:LoadVars = new LoadVars();
// wait for download of imageInfo.txt file
myLoadVars.onLoad = function(){
loadFactor();
}
function loadFactor(){
myPercent.text = myLoadVars.myFactor;
}
myLoadVars.load("factor/factor.txt");
thanks,
Urig
View Replies !
View Related
String To Number
hi every1,
Ive been struggling with this for a while now, and I'm sure that this is pretty simple thing to do but I just cant reach it :P
How do I convert a String to number?
code:
Code:
var n:String = "123";
var t:Number = n;
trace(n); //1067: Implicit coercion of a value of type String to an unrelated type Number.
THKX
::edit:: pretty dumb example (duh) :P
View Replies !
View Related
The Value Of A String Number
I've used ActionScript for five years. Suddenly, I can't figure out how to derive the value of a numerical string expression.
How do I make "3" into 3???
I can't take this...
Any help would be immensely appreciated.
- Paul
View Replies !
View Related
XML String To Number
Hi,
I read an XML file containing numbers. Then I want to do mathamatical calculations on these however I can't seem to convert them to numbers all I get is NaN. here is my code
ActionScript Code:
function loadOldValue(TheNum) {
trace(TheNum);
var Yposition= new Number(TheNum);
trace(Yposition );
}
This outputs fine for the first trace but NaN for the 2nd trace which prevents me from doing any calculations.
Thanks for any help.
View Replies !
View Related
String To Number...
Code:
on (release) {
var LV:LoadVars = new LoadVars();
LV.load(_root.spyderbaby);
LV.onLoad = function() {
U();
};
function U() {
LV.rating = Number;
slipknot = LV.rating;
song = _root.spyderbaby;
final = 1;
trace(star=slipknot+final);
trace(rating=star/2);
loadVariablesNum("shout.php", 0, "POST");
_parent.gotoAndStop(3);
}
}
Here is the thing, slipknot is equal to 3.
When flash executes trace(star=slipknot+final);
it outputs 31
Instead of adding 3 +1 to make 4, it puts together 3 +1 to make 31...
Then it divides 31....
Is there a fix for this?
Any help is appriciated.
Thanks for your time
~Gabor
View Replies !
View Related
String To Number?...
This is really easy I think, but I just couldn't find out how to do it...
How do I get a string converted into a number?
So, if I had "2" and "5", for example, I'd want them to add together to be 7, not "25"...
I dunno if this information is necessary, but I have a long string of numbers separated by commas. I'm using split(",") to put them into an array. Then, I want to add, say, array[0] + array[5]...
Thanks...
View Replies !
View Related
String To Number
Hi, does anybody know how to convert contents of a string to numbers?
I've made 2 dynamic textbox with contents that vary, as long as it's number (i use the 'restrict' method on the input), depends on the input from the user.
the problem is i want to compare the contents of the 2 box.
generally it works fine, but when it compares 2 digit number with 3 digits number, all is lost. for example, i want to compare 72 with 108, the result is 72 is greater than 108.
i tried to debug the movie, watching the variables, and it turns out that flash read the content not as 72 and 108, but as "72" and "108" (which is a string), so i'd have to convert them to number first before i can compare them, right?
the question is how? i've browsed the help topics, and the clostest i cand find is number.toString, but not the other way around.
anybody can help me?
thanks in advance
View Replies !
View Related
XML : I Want A Number, Not A String
Ok,
I'm loading data from an xml file.
Anything loaded from it is a string.
Later, I want to be able to do some maths, say:
aBetterNumber = xmlLoadedVar + aNumber;
aBetterNumber just turns out to be the two variables concatinated together.
Any thoughts?
View Replies !
View Related
XML : I Want A Number, Not A String
Ok,
I'm loading data from an xml file.
Anything loaded from it is a string.
Later, I want to be able to do some maths, say:
aBetterNumber = xmlLoadedVar + aNumber;
aBetterNumber just turns out to be the two variables concatinated together.
Any thoughts?
View Replies !
View Related
I Get A String Instead Of A Number...
I have a movie clip that makes a hittest to another movie clip, and when it does that, the meaning is that it has to sum up 3 to a global variable. But instead it gives me 33. That is, it makes a String. This is my code:
I initialise the variable in the following way:
_global.gold=3;
PHP Code:
onClipEvent(enterFrame){
if(this.hitTest(_parent.mc2)){
if(_root.vitamin >=1 and energi ==1){
energi=0;
_root.gold += 3;//this give me 33 ..!
}
}
}//enterFrame
What is the problem - and what is the solution? Thank you very much.
View Replies !
View Related
String To Number
Hi,
when I load a var from a text file my movie read a number for string
...
I load the var1=200 but my movie read var1="200"
how I can convert this ?????
please help..
View Replies !
View Related
String Instead Of Number
Last edited by Anik : 2007-11-28 at 09:07.
This has got to be simpler than I think it is.
I've got this AS:
ActionScript Code:
getURL("javascript:Resize('main',1040);");
And I want to replace the "1040" number with this...
ActionScript Code:
this.bkgnd._height - 184 + home01._height
Here's what I have now... but it's not working.
ActionScript Code:
getURL("javascript:Resize('main', this.bkgnd._height - 184 + home01._height);");
Any help?
Thanks!
View Replies !
View Related
Number Or String => String
Hello people,
I have a function wich gets a number, this could be like 12.5(=number) or like "12.4"(=string).
I want the variable always to be a string;
function to_string(a_getal) {
// This is where the code should be
// if (a_number = [a number]) {
// a_number = string(a_number)
// }
trace(a_number.length); // This won't work if it's a number
trace(a_number);
}
to_string(12.4);
to_string("12.4");
Please, help!
Mzzl, Chris
View Replies !
View Related
Converting A String To A Hex Number...
I am currently storing a serious of details as hex numbers and then converting them back to strings to work with them as scores.
Once I have checked against the 'highest' score I need to update these strings back into hex.
How can I detect they are above 9 and convet to appropriate hex values... Is there a reverse of the ParseInt command I can use ??? Helpme please - confused maths dropout!!!
burt
View Replies !
View Related
Getting Line Number Of A String
Heya people!
The Problem:
I have a string variable (some text in it).
Say it is like this:
>< Abc abd
>< dfg fgd
>< lka lak
The >< present some kind of markers.
How can i find out on which LINE (Scroll line) in TEXT field those markers are once i put that variable into TextField.
View Replies !
View Related
My Variable Is A String When I Want A Number?
Hi I have mc's named Day0, Day1, Day2 etc. I use this to extract the number from teh name
Fetch = _name.substring(3, _name.length);
it seems I end up with flash regarding Fetch as a string because when I do this to check
ArrayPos = Fetch+2;
flash puts the 2 onto Fetch as a string rather than doing addition.
How do I change this so that Fetch is a number?
thanks mark
View Replies !
View Related
Joining Number And String
I have a number which is part of a preloader, counting up percentage, it is in the variable "perc"
this works fine but when I try to append the percent sign with this script and display it in a textbox (variable nperc) I just get the number
nperc = perc +"%";
this is straight from a tutorial here at flashkit, does this need correcting?
tutorial is
http://www.flashkit.com/tutorials/Ac...60/index.shtml
thanks
mark
View Replies !
View Related
Loaded String To Number?
Problem:
As I load variables from an external file, I have one var which is assigned a value of a number, let's say, 4. When the var loads into the movie, I need to do numeric operations with it, but I cannot, since the var is considered a string (has escapes included, a "4
" or so in debugger). When I Int(var) it, the value becomes 0.
Is there any better way to make it numeric?
View Replies !
View Related
I Need To Convert A String To A Number
Hello all,
I have a value stored in a variable called "numba"
I get the value like this:
numba=this._name.substring(6,this._name.length);
the value is a string, when I trace(numba) I get something like this:
0
1
2
3
4
I want to add a value of 1 to the variable called numba.
The problem is that the value of the variable numba IS A STRING. so when I try to add 1 to it like this:
newNumba=numba+1;
the trace looks like this:
01
11
12
13
14
I want it to simple return 1,2,3,4,5
how can I convert my string(numba) into a real number?
I have tried turning the string into an object but it didnt work out.
Much thanks to any takers,
~Apolo
View Replies !
View Related
Converting A String To A Number?
I need to turn a string into a number that you can do math with!
My example:
thestring = "h5";
splicedsuit = thestring.charAt(0);
splicednumber = thestring.charAt(1);
(splicedsuit = "h"; splicednumber = "8")<not displayed
Then I need to do Math like
whatIneed = 9274 + splicednumber
If I check the variables durning the movie it says
whatIneed = 92748
but I need it to say 9282 and acually add them together not combine them.
Thanks In Advance!
Chris
View Replies !
View Related
Convert String To Number
Hello if anyone can help with this probably simple issue....
I load some variables from a database or textfile and some of those are numbers. Now I tried to convert them using parseInt() and that works fine, however if I try to convert an integer value, for example 1.33 it goes wrong!
Any suggestions?
View Replies !
View Related
Extracting Number From String
Ok I have created a bunch of buttons dynamically and I want to extract the number at the end of the instance name. I have done this before but all the names in the array were the same length with a number at the end.
This time all the instance names are different lengths but they all have at the end of them _mc0,_mc1,_mc2 etc.
I need to get that number so I can call a picture to load from another array called picMax.
Code:
btn.onRelease = function() {
_root.select = _root.picMax[Number((this._name).substring(bla))];
};
btn is a variable with the path to all the dynamic clips.
The problem with this is I don't know what bla would be in the substring().
I need a way to extract the number at the end of the instance.
Example of instance names
Code:
Adele_mc0
Adriana_mc1
Antonina_mc2
Agnes_mc3
Etc
View Replies !
View Related
String To Number... This CANT Be Impossible...
//I'm trying to pull a formula from a text string...
//
//For simplicity sake I just created a string called "myFormula"
//the crux of the problem is that the formula has to be input by
//the user, so it must always start as a string.
//Here is the code, why does this not work?
//or more to the point, can anyone get it TO work?
//
myFormula = "(10 + 20)/2";
trace(myFormula);
//how do I get it to display "15" ???
//
//doesn't work...
trace(eval(myFormula));
//doesn't work...
trace(Number(myFormula));
View Replies !
View Related
String To Number Flash MX
how do you to turn a string into a number so numerical calculations can be performed on the original string. i know about toString() i want to go the other way around
numberString = "102";
trace(numberString+20);
retruns -- 10220 !!!
i want it to return 122
View Replies !
View Related
String Who's As Long As A Number
Hello!
My problem is:
I'd like to generate a string who is X times long (x = number).
The string should contain X-times a -.
example:
x = 10;
// distance = "----------";
x = 1;
// distance = "-";
x = 0
// distance = "";
this should work automatically!
View Replies !
View Related
How To Convert String To Number?
I have an external text file and it's content is simply "quantity=3".
Then I loadVariablesNum to load this external text file into flash.
As expected the variable called quantity will be a string of "3".
I want to change this string to a number.
So I put in this statement "var newquantity = Number(quantity)".
Unfortunately this doesn't convert the variable quatity from a string to a number?!!
I know that the above statement will work if the variable "quantity" is defined internally, instead of loaded externally.
My question is how should I load a number into flash ... instead of loading a string. Thanks
View Replies !
View Related
Converting A Number To A String AS 2
Hi:
I've been trying to convert a number into a string (It's easy in other langauges) but its got me baffled in AS 2.0. I'm still very much a n00b at Flash. MX 2004 is my first and only version.
In a class (theScore) I increment a number n_numberRight. Return that to the main part of the code theScore.numberRight
I've tried the code below:
code:
public function get numberRight () : String
{
var s_ScoreRight : String;
var n : Number = new Number (n_ScoreRight);
s_ScoreRight = n.toString ();
trace ("Number = " + n_ScoreRight + " String = " + s_ScoreRight);
//the trace shows correct values.
return s_ScoreRight; // return this should be string??
>> this works if the return type is Number but I still want a string//return n_ScoreRight;
}
The return value is correct in a trace, but if add
code:
var sOut:String;
sOut = theScore.numberRight();
trace(sOut); // undefined ??
I want to pass that string then to a textfield
textfield.text = sOut;
Help, please, and thank you.
View Replies !
View Related
|