Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Problem With Txt Field From Getting From Number To String



Hello, I've got a problem with textFields in an orderlist.

I've got a orderlist in which people can order food. They can choose between 4 different kinds of bread and they can also put in a number from 1-99 for every kind of bread, the prices are added to a total.

Here's the problem: The textFields are empty but the user can fill in the numbers himself. (the txtfields are empty because I think that is nicer to see). If the user makes a mistake for example: he filled in the number 2 (two white bread) but he wanted brown bread instead and he deletes the number 2 with backspace, then the (variable) texfield 'total' displays NaN (I think that the backspace converts the textfield from a Number to a String or something like that.) If you fill in the Number '0' then it displays the total again.

Do you know how to avoid the txtfield from displaying the NaN? Or do you have another solution?

Please help.

Thanks in advance!

Jeron



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-28-2001, 03:33 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Getting The Input Text Field As A Number And Not A String
Hi there, i am having problems when using something that the user has inputted through an input text field in a variable with a :Number type. i get the error "1067: Implicit coercion of a value of type String to an unrelated type Number." when i try and test the movie, and my actionscript knowledge is not good enough to think a way around this problem. any help you can give would greatly help. i will post some of the action script below.

Thanks for your help. :-)

the radiusX_txt, radiusY_txt and speed_txt are the instance names of the three input text boxes.


ActionScript Code:
var centreX:Number = stage.stageWidth/2;
var centreY:Number = stage.stageHeight/2;
var radiusX:Number = radiusX_txt.text;
var radiusY:Number = radiusY_txt.text;
var angle:Number = 0;
var speed:Number = speed_txt.text;
radiusX_txt.setTextFormat(

var drawMC:MovieClip = new MovieClip();
addChild(drawMC);
drawMC.graphics.lineStyle(10, 0xFF0000);
var startX:Number = Math.cos(angle) * radiusX + centreX;
var startY:Number = Math.sin(angle) * radiusY + centreY;
drawMC.graphics.moveTo(startX, startY);

button_mc.addEventListener(MouseEvent.CLICK, addEvent);
button_mc.buttonMode = true;
function addEvent(e:MouseEvent):void{
 trace(radiusX_txt.text)
 trace(radiusY_txt.text)
 addEventListener(Event.ENTER_FRAME, drawCircle);
}
function drawCircle(e:Event):void {
 
}

thankyou again for any advice you can give

HELP: How To Detect Line Number/string Under Mouse In A Static/dynamic Text Field
Hi folks,

Is there a way to detect the line number/string under the mouse in a static/dynamic text field, like we can do in Macromedia Director?

Need help urgently.

Thanks in advance.

Yossarian,
Mumbai, India.

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?

How Can I Put A Number And A String Together So It Ends Up Being A String ?
How can I put a number and a string together so it ends up being a string ?


This doesn't work:
----------------------

somenumber=1;
somestring="File";

combination=somestring + somenumber;

----------------------

At the end i want to have this:

combination="File1";

Can anyone help ?

[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.

How Can I Add A Number To A String? Like As In 2+1=3 Not As In 2+1=21
How can I add a Number to a string? Like as in 2+1=3 not as in 2+1=21

I am making it so that after someone crosses a frame each time it adds a number and when it gets to 8 it does some other action. Would it be something like this? 'tracksplayed= +1;' Thanx in advance.

String To Number
I have a string which is "7". But i need it to be the number 7.
What shall i do?
Thanks in advance!
bye

String To Number
I have a string which is "7". But i need it to be the number 7.
What shall i do?
Thanks in advance!
bye

String To Number
How do I convert a string variable to a number variable?

String To Number Bug?
Hi,
I have the following code:

a="013";
b=Number(a);//returns 11

Is there a way that the string a can be converted to the right '13'?

greetings
Patrick

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?

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.

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.

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

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

String To Number
How's about it?

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

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

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.

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

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...

String To Number
trying to compare values but value is seen as a string so it wont add.

i.e.

var x = value from XML file. such as 1111
var y = x + 5

output is 11115
should be 1116

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

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?

String To Number
How do I convert a string (e.g. "100") to a number or boolean?

I know this is probably quite basic, but it escapes me at the moment.

Thanks
Alfred

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?

String Into Number From .txt
Hello,

I've the following problem with getting values from a .txt file into flash.The problem isn't to get the Vars into the flash but to convert a string into a number. For example: the .txt file looks like this:

&t1=200&t2=400

now i want to add both numbers out of the file. I get the values into my textfields,but then Flash don't know how to add these "strings".
Flash code looks like this:

onClipEvent (enterFrame) {
    loadVariablesNum("test.txt", 0);
    sum = _root.t1 + _root.t2
}

Is it possible to add the numbers? Or is it only possible to do this with javascript
instead the txt file?

Thanks for any comment!

Number -> String
I know there is parseInt() for String -> Number, but how do I convert the other way around?

Cheers,
Lister

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.

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..

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!

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

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

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.

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

String To Number From TXT File
Ok, i load var from a txt

var="4"

how do i convert it to number 4?

i tried with Number and similar, but stupid thing just realizes that this is from a external file and will not change it !!

any ideas?

Help, My Number Is Trapped In A String And Cant Get Out
How do I convert a number trapped in a string ("2"?) I'm not that tallented when it comes to strings (assuming i'm tallented at anything!)

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

How To Transfor String To Number
i work whit director and whit director you can only send string to flash

i would send a number to flash like 1 but i receive "1"
inside flash how i can transfor this "1" into 1

thx

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

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?

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

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

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?

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

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));

Convert String To Number
Hello,

i have this: "01". How to convert to this number: 1?

Thanks,
Miguel

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

Copyright © 2005-08 www.BigResource.com, All rights reserved