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




Minimun Number = 0



hey, currently i have this on a frame.

//variables
minNum=20;
maxNum=60;
rndNum=Math.ceil(Math.random()*maxNum-minNum);

//command
_root.character1CurrentHP-=rndNum;

//end.

okay that is working fine.
lets say that character1CurrentHP = 10 and the rndNum = 21

that will leave the character1CurrentHP = -11

how do i make it so that once the number goes below 0 the character1CurrentHP stays at zero.?


please help.



ActionScript.org Forums > Flash General Questions > Other Flash General Questions
Posted on: 03-27-2003, 08:15 AM


View Complete Forum Thread with Replies

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

Shared Object To Store A Unique Id Number Var And Frame Number Var
Hi, I am a complete novice to action script when it comes to objects. I know what I want to do is done with the shared object. Basically I want to create a tutorial that stores a cookie on the users’ machine with a unique id variable telling flash what frame the user was at last. When the user revisits it would prompt "continue where left off or start the tutorial over. I read the action script dictionary regarding the shared object, but being a designer I really need to visualize it before I can comprehend this.

Thanks,

Justin

Limmiting A Number To A Certian Number Of Decimal Places
Ok for a currency i have

gold.silver which is the same as say 1.35g with 'g' being gold

When I calculate with tax it often goes to 10 decimal places. How do I limmit the amount of decimal places that it can access?

Random Number Then Delete Number Till Reset
Last edited by pixcels : 2006-10-18 at 22:41.
























I am trying to create a type of quiz thing. It is a stand alone move and can not have anything loaded into it.

Problem:
I need a random item from an array, then after the item is displayed I need it to delete itself so that it will not show again. After the array is down to the last item it calls in the array again and starts all over.

Below is code that I have found but it does not delete the array item after it has been show from the array, or restart.


Code:
Array.prototype.shuffle = function() {
var shuffledArray = [];
var copyArray = this.slice(0);
for (var j = 0; j<this.length; j++) {
randomNo = Math.floor(Math.random()*copyArray.length);
shuffledArray[j] = copyArray[randomNo];
copyArray.splice(randomNo, 1);
}
return shuffledArray;
};
testArray = ["1", "2", "3", "4", "5", "6", "7"];
newArray = testArray.shuffle();
//Text area component
theText.text = "newArray = "+newArray
//Button component
theBtn.onRelease = function(){
newArray = testArray.shuffle();
var tempArray = Math.floor(Math.random()*testArray.length)
var totalArray = Math.floor(tempArray+=newArray[0])
var slicedArrary = tempArray.splice(0)
theText.text = "newArray = "+newArray[0]
}

AS2 - Image Set Number Of Rows/dynamic Colum Number
I have a simple image gallery that is loading images in, creating movieclips, and then lining them up into 3 columns and rows. This woks fine as long as there is only 9 images, but I have more then that. If I have it pull more then the 9 it adds in more rows I need it to add in more columns no more rows.

Here is the function that creates the gallery:
title_array is the array of images.

Code:
function createGallery() {
nbrColumns =2;
leftMargin = 7;
topMargin = 5;
cellWidth = 165;
cellHeight = 165;
//thumbnails.setMask(albumHolder.albumHolderMask);
for (i=0; i<title_array.length; i++) {
thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
var cellX = i % nbrColumns;
var cellY = Math.floor(i / nbrColumns);
thumbHolder._x = leftMargin + cellX * cellWidth;
thumbHolder._y = topMargin + cellY * cellHeight;
thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
thumbLoader.loadMovie(title_array[i]);
}
}

Script To Change Number To Formated Number
Hi, is there a free script to change a number to formated number (u know with dots and commas)
I know I probably can make my own.. but.. i'm in a hurry
thanks

Round Number To Next Number That Has Only Zeros Behind It (ie: 20, 100, 3000)
I want to make a graph and I want the highest number in the graph to be a solid figured number.

so if the highest part that needs to be graphed is 12,000 I want the graph to go up to 20,000 ( the next highest number with only zeros behind it.)


for instance I want to round:
11 to 20
253.3454 to 300
4500001 to 5000000


I am sure I neet to use Math.Ceil() in combination with something else but I am unsure how?

any suggestions?

THANKS!

Random Number Variable That's Different From Previous Number
I have this line of code in my game that works great. However it would work even better if when it the code was executed the next random number was not the same as the one before it. For example if "speech" is on frame 6 when the code is executed I would like the random number to be between 2 and 12 but not 6. (I don't want the same frame to come up as it confuses the kindergarteners and preschoolers using the program.) Here's the code that's working for me now.


ActionScript Code:
speech.gotoAndStop(Math.floor(Math.random()*11)+2);

Need Urgent Help How To Check If The Generated Number Is A Whole Number
Hi,
I have a simple issue but I need some assistance. I am calculating a number and the result number sometimes a whole number but in some cases decimals are present. Decimals do not need change but whole numbers need to change. So for example if the end result is "6" I need it to show it as "6.0" in a field beacuse that is the way the calculator should display it according to request.
How can I check that the result number is a whole number and then add ".0" to it?
I just included a simple script below.

if (outputnumber == ?) {
resultNum = Number(String(outputnumber+".0"));
} else {
resultNum = outputnumber;
}

Thanks,
Attila

Method To Check If A Number Is A Decimal Number?
i was wondering if there 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...please help!

TextField - Number Of Lines, Number Of Characters
Hello,

I'm trying to get some insight on the textField object in flash.

I know how to get the textfield length and number of characters. But I need to know more.

Is there a way to get the number of characters on a line in a multiline textfield?

Thank you in advance.

Decimal Number To Binary Number ?
In ActionScript, I can use parseInt to convert binary num to decimal number. But how can I convert decimal number to binary number? I try find in AS dictionary but there isn't result.
I have an input textfield to enter the decimal number, and an other to display the binary number.
Please tell me how...Thx U,

Variable Number = Frame Number#$%@&*
I have a movie Clip called “percentage bar” and a variable text box called “percentage”.
Now I get a number from VB and this number is = to the value of ”percentage” (my variable txt box).
The Movie Clip has a 100 frames… here it comes I need to have whatever the variable number (“percentage”) is to determine which frame the movie clip (“percentage bar”) is standing on.

This has to be possible, don’t it?

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?

Variable Number = Frame Number ?
Here's an easy one for anyone who knows actionscript...
I have a variable text box called "percentage" and a movieClip called "progressbar" (100 frames).
I want the number in my variable txt box "percentage" to tell "progressbar" to go to the corresponding frame number.
for instance if the number in the txt box is 15 the movieclip has to go to frame 15.

Thanks
- a Designer, forced to be a programmer.

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

Sum Of All Number From 1 To [place Number Here]
A nifty little piece of code I came up with while trying to figure out my combinations problem.

It is the result of me forgetting to calculate th product, and instead calculating the sum; kind of stupid, I know.

Not really anyting new, just optimal enough for me to like it.


ActionScript Code:
//calculates the sum of a numbers between 1 an i
function sum(i:uint):uint {
    i = (((i)*0.5)*(i+1));
    return i;
}
var n:uint = 25;
trace("sum of all the numbers
from 1 to " + n + "
is equal to " + sum(n));


and here it gives you the option of telling it where to start, and where to end.

ActionScript Code:
function sumAB(a:Number,b:Number):Number{
    if (a>b){
    return ((a-b+1)*((a+b)*0.5));
    }
    return ((b-a+1)*((a+b)*0.5));
}
var a:int = -5;
var b:int = -2;
trace("the sum of " + a + " through " + b+ " is " + sumAB(-5,-2) + "....");

Pick A Number ...any Number
I have 5 files text files that look some thing like this

Code:
primeRow_1=2,3,5,7,11,13,17,19,23,29,31,37
&primeRow_2=41,43,47,53,59,61,67,71,73,79,83,89
&primeRow_3=97,101,103,107,109,113,127,131,137,139,149,151
&primeRow_4=157,163,167,173,179,181,191,193,197,199,211,223
&primeRow_5=227,229,233,239,241,251,257,263,269,271,277,281
&primeRow_6=283,293,307,311,313,317,331,337,347,349,353,359
&primeRow_7=367,373,379,383,389,397,401,409,419,421,431,433
&primeRow_8=439,443,449,457,461,463,467,479,487,491,499,503
&primeRow_9=509,521,523,541,547,557,563,569,571,577,587,593
&primeRow_10=599,601,607,613,617,619,631,641,643,647,653,659
&primeRow_11=661,673,677,683,691,701,709,719,727,733,739,743
&primeRow_12=751,757,761,769,773,787,797,809,811,821,823,827
&primeRow_13=829,839,853,857,859,863,877,881,883,887,907,911
&primeRow_14=919,929,937,941,947,953,967,971,977,983,991,997
&primeRow_15=1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069
&primeRow_16=1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163
&primeRow_17=1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249
&primeRow_18=1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321
&primeRow_19=1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439
&primeRow_20=1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511
I call the file into flash like this

Code:
primeFileNumber = 1;
fileName = "system/primes_"+primeFileNumber+".prm";
loadVariablesNum(fileName, 0);
and process like this

Code:
prime_row = 'primeRow_'+random(20);
prime_ind = 1;
primeNumber = prime_row[prime_ind];
trace(primeNumber);
my problem id that I can not get a value from the file into the var primeNumber.

trace(primeNumber) just keeps reporting undefined.
Any Ideas...

I'm trying to use two numbers to pice a prime number from a random list, this is repeated twice to gain two number to form the base of cypher system.
The rest of my system works, I kust can not get the numbers of of the files.

I also need to know how to drop the vars load with loadVariablesNum.

Extract A Number From A Number
I've got a 5 digit number, for example 12345. I want to extract the second last number, in the example it would be 4. I'm sure there's a way to do this, but i don't know which phrase to use when i google. Can anyone please help me? Thanks!!

Check If Number Is Whole Number
i would like to know how can i know if the result of a variable is a whole number or not.
like...
var i++;
if(i =wholenumber) {
....
}

i need something like this. the number must be a whole number with no decimals or fractions
thanks

Check If Number Is Whole Number
i would like to know how can i know if the result of a variable is a whole number or not.
like...
var i++;
if(i =wholenumber) {
....
}

i need something like this. the number must be a whole number with no decimals or fractions
thanks

Why DOES It Work With A Number, And Not With A Var Containing That Number?
I have a flash movie, in which a click on the button should evoke an action, only if some value is smaller than lets say
1200. if I go like:

if(something < 1200){go and do this;}
then all works fine.

but if I go and do this(which should be the same...)
if(something < numbervar ){go and do this;}
in which numbervar is defined in the same timeline as the button like this:

var numbervar = 1200;

it does not work. Nothing happens....
Whats the difference between, 1200 written down, and 1200 via a var?

Why does it not work?
Hope someone can help me out here.
thanks Sam

I Know The Line Number. I Need The Last Char Index Number Of The Line.
Hi,

I have a multiline wrap textbox which is dynamic and has a variable assigned to it. I am importing text into this textbox. If the amount of text exceeds the height size of the textbox I want to split the text into two parts, so the part which exceeds the textbox ( the text which is not visible unless you scroll down) will be moved into another textbox located below the first textbox.

I know how to get the location of the last visible line in the textbox. I simply use

LastVisibleLine=MyTextbox.bottomScroll;

Now I have the location of the last visible line so my question is:

How can I get the location of the last character in the last visible line in the textfield?

Is it possible to count the lines in a textfield when the text is wraped. I've tried to count "
" and "
" and they don't detect the wrapping.
( Wrap: When the textfield detects if a line has reached the width of the texfield it automatically breaks the line so it will fit the textfield. )

Thank you.

I Know The Line Number. I Need The Last Char Index Number Of The Line.
Hi,

I have a multiline wrap textbox which is dynamic and has a variable assigned to it. I am importing text into this textbox. If the amount of text exceeds the height size of the textbox I want to split the text into two parts, so the part which exceeds the textbox ( the text which is not visible unless you scroll down) will be moved into another textbox located below the first textbox.

I know how to get the location of the last visible line in the textbox. I simply use

LastVisibleLine=MyTextbox.bottomScroll;

Now I have the location of the last visible line so my question is:

How can I get the location of the last character in the last visible line in the textfield?

Is it possible to count the lines in a textfield when the text is wraped. I've tried to count "
" and "
" and they don't detect the wrapping.
( Wrap: When the textfield detects if a line has reached the width of the texfield it automatically breaks the line so it will fit the textfield. )

Thank you.

Choosing A Random Number (that Isn't The Current Random Number).
I have a loader movie, that randomly chooses a clip to load from an xml list. Sometimes it 'randomly' chooses the same number which makes it look like the loaded clip is mistakenly looping (skipping). Here's the code:

Actionscript Code:
function randomImage() {
    if (loaded == filesize) {
        fadingPeople._alpha = 0;
        numberSelected = random(total);
        fadingPeople.loadMovie(image[numberSelected], 1);
       
    }
}

The code runs, waits for x seconds and then fire again. What I'm wondering about is how would I go about telling the random function to choose a random number that's NEQ numberSelected.

Thanks for any help.

How To Change ODD Input Number To EVEN Input Number?
Hi Flash Friends -

I'm hoping you can help me out with an Actionscript question...I've built a small commerce site in Flash MX designed to help women find their true bra size, however, I must make it compatible with Flash player 4.

I'm having trouble trying to figure out how to convert one of the input variables to an EVEN number if the user enters an ODD number.

My input text variables are "bandinput" and "brainput" -- and I need to ensure that bandinput is always an EVEN number.

My code is below and I really hope that someone can lend me a hand with this one ;-)

Thanks!
Jenny

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

on (release) {

if (brainput-bandinput eq 0) {
cupsize = "AA";
} else if (brainput-bandinput eq 1) {
cupsize = "A";
} else if (brainput-bandinput eq 2) {
cupsize = "B";
} else if (brainput-bandinput eq 3) {
cupsize = "C";
} else if (brainput-bandinput eq 4) {
cupsize = "D";
} else if (brainput-bandinput eq 5) {
cupsize = "DD";
} else {
cupsize = "F";
}

sizeoutput = bandinput add cupsize;

play();
}

Not-a-Number
Why is this, is it some kind of big:

a=Math.pow(0,2);

in publish: a=NaN
-----------------------------
but if i put it like this:

a=0 * 0

in publish: a=0
-----------------------------
and i really need the power 2 operation

Any suggestions?

Does Number = 11 ?
ok .... i've used this code all the time but for some reason it decided to not work in my movie . Can somebody please tell me why ? Well it's basic code i'm sure you'll get it .


Quote:





var number = number;
number = number+1;
if (number=11) {
gotoAndPlay ("second");
} else {
gotandplay("first");
}

Max Number Of Mc's?
Hi , thanks for looking

Question:
Is there a limit or maximum number of Movieclips you can Duplicate and assign zdepth's ?

I got 120 mc's on-screen and it's growing quick
I can see the movieclips building up and placing, but then my movie goes blank .
Debugger tells me I'm still on frame 13,
(which is where all the duplication takes place.)
_alpha = 100, _visible = true , variables are present.

by all means it should work.

(Can't post code cause it's under NDA, sorry)

thanks for the help.

Help Regarding More Number
Hi

I have tried to build a new version of the flash movie

http://www.flashkit.com/movies/Inter...6294/index.php


the thing is that i have tried to change the number of slides and channels to 22 because i'm a team coach for a women soccer team with -........ 22 players

could anyone try to help or just try to explain me how to correct the version from above

Number From 0 To 99
is there a way to specify some number from 0 to 99 in switch or if statement. I need to do something like this.

switch(myVariable){
case number between 0 and 99:
trace(myVariable);
case number between 99 and 100:
trace(myVariable);

Thanks

Its A Number, AND NaN Help?
Code:
totaljobs = jobcount * 10;
trace(totaljobs);
trace("total jobs is a : " +typeof(totaljobs));
This one is stumping me! The trace will out put:

NaN
number

So WHICH IS IT? Any suggestions?

Number Of Tries
I am trying to make the correct answer appear after the "check" button is clicked again after the number of failed attempts.

when you click on the "check" button for the first time, the "wrong. try again" msg appear.

then you type the wrong answer and hit the "check" button for the second time, the "wrong. try again" msg appears again

Finally, if you type the wrong answer for the third time and hit the "check" button, the correct answer will appear.

can u help me with me? thanks!

attached is my fla file.

Any Number
is there a way of seting a variable to be any number?
for example
n= real numbers
or
n=infinite
or
n= any number between 0 and 999

:Number ?
I've a verry stupid problem again;

Well I'd like to multiply two (or more) numbers but flash just places those two numbers bahind each other
I'm using the += function so every time someone clicks on the button a value will be multiplied with the previous.

example:
on(release){
a += someValueString}
He returns if a = 0 from the beginning:
01254321 (he just adds the someValueString behind it)

Can someone solve this ?

kind regards flax

Not A Number = 0
I have an input text box that starts out with the path inside it. I want it to start with a zero. How do say: if not a number make this input box 0?

Odd Or Even Number?
Hi
I been looking for a way to check if a number is odd or even..I can't find a function in flash that does it..I could go into calculations of some bizaare kind..but I rather not if there was an easy way around it, I can't find anything in the old threads...wich I find weird..is it so hard?

Thanks

ohh by the way.. not zero and of course only whole numbers..

Value As Number?
Got a problem. I´m loading a XML with a value, and then try to set a vertical slider to that value (see below).
With the first function I get the value into my testVar but the slider does not move...
When I try to convert the variable (the second function) with Number(#) I get NaN in my testVar-field, and of course my slider doesn´t move.
What the h***l is wrong?!?!
FIRST VERSION:

function loadSliderValue() {
mySpeed = new XML;
mySpeed.load("../tempspeedservice/cameraservice.asmx/GetSetCameraSpeed?GetOrSet=GetSpeed&speed=0");
mySpeed.onLoad = function(success) {
if(success) {
sliderPos = mySpeed;
testVar = sliderPos;
_root.speedSlider.vertFader._y = sliderPos;
} else {
testVar = "Not loaded...";
}
}
}

SECOND VERSION:

function loadSliderValue() {
mySpeed = new XML;
mySpeed.load("../tempspeedservice/cameraservice.asmx/GetSetCameraSpeed?GetOrSet=GetSpeed&speed=0");
mySpeed.onLoad = function(success) {
if(success) {
sliderPos = Int(mySpeed);
testVar = sliderPos;
_root.speedSlider.vertFader._y = sliderPos;
} else {
testVar = "Not loaded...";
}
}
}

Fix A Number
I want to know how can I fix a number? Suppose the out put of an expression is 43.4939393403 I want to remove all the number after the dot (including the dot).

The out put of the expression might be 0.39348309483 or 393493.34349343948. Means the number before the decimal is not fixed. How can I do it?
Thanks in advance.

Number() And XML
Code:
onClipEvent(load){
var width2:Number = Number(_root.picArray[0][2])
var height2:Number = Number(_root.picArray[0][3])
this._xscale = (100/width2)*100
this._yscale = (75/height2)*100
trace(width2)
trace(height2)
}
the width and height should be 2048 and 1536 respectively, ive traced the array separately and it does contain the numbers the array instances contain those numbers taken from an xml file however tracing width2 and height2 gives me NaN which is why i used Number however Number() and width2:Number and width2 = new Number() dont work separately or together to convert it to a number.

I want to cry!

Odd And Even Number
I'm trying to get a row of numbers from 1-2

Code:
for (var i = 0; i< max; i++) {
var oneTwo=i%2
trace("oneTwo :"+oneTwo)
}


The problem with this is it gives me

Code:
0
1
0
1
0
1
ans so on.

What I need is

Code:
1
2
1
2
1
2

Number And Xml ? Possible?
I am trying to load into flash file a variable from xml file. I can even trace it.
But when I am trying to get it to work in a color transformation, it isn't working.

Code:
var my:Number = this.firstChild.childNodes[0].childNodes[3].firstChild; //getting a "number" (e.g. 99) from an xml file, I skipped the xml file loading process
var trans:Transform = new Transform (_root.bookmarks_btn.bookmarks_btn_bkg);
var bookmarks_btn_bkg:ColorTransform = new ColorTransform (my, my, my, 100, 0, 0, 0, 0);
trans.colorTransform = bookmarks_btn_bkg;

trace (bookmarks_btn_bkg);
//(redMultiplier=NaN, greenMultiplier=NaN, blueMultiplier=NaN, alphaMultiplier=100, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)
redMultiplier=NaN, greenMultiplier=NaN, blueMultiplier=NaN
Where could be the problem?

Get Number From A .txt
i have a slide show and when i click a btn it moves my MC(instace name: moveMC) to the left or the right a certain number of pix.

i need my button(prev) to go to frame 20 when my MC(instace name: moveMC) is greater than a certain _x point controlled by a number in a .txt file

heres my newbi code can you fix it

Code:
var getNum:Number = howfar.txt;
var Nav:Number = moveMC._x();

if (nav < getNum){
_root.prev.gotoAndStop(20);
}


thanks

[F8] Any Number
ok, In my game each time the player shoots a new bullet is created. each bullet has its own unique name (bullet1, bullet2, bullet3, etc.). there is another movieclip which has to do a hit test to see if any bullet has touched it. but how can I check if it has colided

I currently have this code:

Quote:




if (this.hitTest(_root.game.map["bullet"+%NUMBER%].bulletImg) {
//do something
}




I need something to replace the %NUMBER% thing so that it knows when it collides with ANY bullet

Whole Number... Or Not?
I want to evaluate a the result from an equation to see if the result is a whole number. This should be dead simple but I'm not sure how to do it?

eg:

Code:
var A:Number=10;
var B:Number=5;
Var C:Number=4;


firstResult=A/B
/*
firstResult: 10/5=2 - Two a whole number
*/
if (firstResult=wholeNumber ){
trace("this is a whole number");}

secondResult=A/C;
/*
secondResult: 10/4=2.5 - Two point five is a decimal number
*/
if (secondResult=wholeNumber ){
trace("this is a whole number");}
else {
trace("this is not a whole number");
}


Obviousely I have made up 'wholeNumber' but you can see what I am trying to do. If you have a better methode I am all ears!

It's dead simple isn't

Number To Hex
How do I convert a string which is in the form '0x000000'. and convert that into the Number 0x000000?

Using The Number In A Name...
hi
i need to use a number from a name i get
i have an array of thumbnails, when i rollOver them and trace..., i get the name of the thumb, for example _level0.thumbLoader_mc8. is there a way to use the 8 (or any number that will be for that matter) so i can use it in a for function, i need to write a function that goes from 0 to the number of the thumb thats rolled over.
i remember that there is a way somehow, but i dont know how
anyone know?

XML Number?
I am having trouble with my Media Viewer project. It scrolls through a bunch of pictures and displays them using a component. It uses a number to tell it when it's gone through the whole list of pictures and when to start over. I get this number from a XML file. (I don't know how many times im going to use this, so I can't put the number in the flash file). I have, using a test file, gotten it to load the XML. But, when I put it in my Media Viewer, it doesn't work. I think it is because it loads it as a string, and not a number. i have been unsuccessful in converting it. (this will probably be very easy to solve)

Here is the flash file: [ATTACH]Media Viewer[/ATTACH]

I appreciate any and all help.

Hengy

The Number 7.66
Does anyone know how to make Flash interpret the contents of an Input text box as a Number variable?

I thought that something like Number(Input_txt.text) would work, but evidently it doesn't. There is something funny about the number 7.66. Look at this:

This works (traces "Yes"):
onEnterFrame = function () {
if (7.66 == 7.66) {
trace("Yes");
}
};

This doesn't work (ie when 7.66 is entered in the Input_txt text box "Yes" is not traced):
onEnterFrame = function () {
if (Number(Input_txt.text) == 7.66) {
trace("Yes");
}
};

Yet the same code does seem to work with all other numbers...

Is This A Number?
Dear All,

I have created a couple of functions. The PickRandomBox function selects the
first item from a radomised array. The second function takes this value
along with a basic if statement to return a string. The problem seems to be
that the second function does not see the input value, boxcode, as a Number.
A couple of trace statements show me that the array returns an entry but the
if statements doesn't see the value as a number that it can evaluate. I have
tried using the int function to convert the first value from the array but
it always returns a 0.

I am totally confused. It seems as if an element of an array is not a
Number.

Please put me out of my misery.

Alastair MacFarlane



arr: 3,18,27,32,5,9,37,1,12,21
The colour number is: 3
MORAY FIRTH COAST - (Unsure - Box 3)


function PickRandomBox(arr:Array){
arr.randomize();
trace("arr: " + arr);
trace(_root.boxnames[arr[0]] + " - " + BoxCodeDescr(arr[0]));
}

function BoxCodeDescr(boxcode:Number) {
trace("The colour number is: " + boxcode);
//boxcode=27;
if (boxcode == 1 || boxcode == 3) {
return "(Brown - Box " + boxcode + ")";
break;
} else if (boxcode == 5 || boxcode == 15 || boxcode == 25 || boxcode == 35)
{
return "(Airport - Box " + boxcode + ")";
break;
} else {
return "(Unsure - Box " + boxcode + ")";
break;
}
}

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