The AS3 documentation states that if you pass in a string to parseInt that is not a number it will return NaN. However, when I try to compare to NaN the compiler gives me the following error: Warning: 1098: Illogical comparison with NaN. This statement always evaluates to false. The statement is actually true. Comparing to NaN will always return false. How can I compare to NaN to detect if what was parsed was NaN?
if( parseInt("test") == NaN )
{// do something (never gets here)
}
I'm writing an age verification actionscript for a flash project. Right now I have it where if the user is born before a certain year it will allow them to access the swf if not it will deny them. the problem is if they leave the field blank it will allow them access (i'm assuming because a blank field qualifies it as acceptable to the parseInt) so i'm curious as to how to block it so if someone doesn't enter a year it will disallow them from access the swf. here's my code for it
agetext._visible = false; verify_btn.onRelease = function () {
All I want to do is convert a string into a number, I thought it would be easy:
Code:
var stringNum:String="00000000537112" var num:Number= parseInt(stringNum); trace(num); //Result: 179786
I have tried using Number(stringNum) aswell which does not work, all I want it to do i convert "00000000537112" into 537112.I have tried it by removing the 0s at the beginning of the string which works. Is there any way of solving this or will I have to build a function to shave off the preceding 0s?
Can anyone tell me how to convert a String "012" into an Integer 12 using the parseInt or other method? Apparently integers begining with 0 are interpreted as octal numbers...whatever they are.[code]
I have two lines. One is straight and one is curved. Both were created with the Flash Graphics interface. How would I compare the different Y value for the curved line for any given X. In other words, how do I find a point on curve if I used the CurveTo method.
I've searched everywhere and can't seem to find a clear explanation or basic example. How do you compare the elements of 2 arrays to see if there is a match?
The scenario is to create a lotto game that matches 6 user inputted numbers with 7 randomly generated numbers. The 7th number is a special case (eg bonus ball) WOULD LIKE TO SHOW A KIND HEARTED FALSH GENIUS ALL OF THE SCRIPT IF POSS! (its not tooo long) This code works, but it just outputs the default message: There seems to be a problem with my arrays not comparing? Part of the code is: (prioir to this the user inputs numbers, they are copied to text areas beginning with O, on a button press) On a second button press randomly generated number appear to a timer. //compareResult checks how many numbers match between the two sets of numbers to determine winnings.
I have an array which has strings for the key instead of numbers. when i use .toString() on this array, it does not output a string, leading me to believe that .toString only works when you have numerical keys. Is there an easy way I could compare two of the above arrays?
comparing the two bitmapdatas?I'd like to have a function which returns an int (a value of how big the difference is), where 0 means they are identical.Right now I can do it with two for-loops, and getPixel. Then I compare the R-, G- and B-value separately. But it's slow if the images are big.
I would like to compare a string variable to multiple strings. Is it possible?I wrote a pseudo code of my own which doesn't cause an bug/error report,but it doesn't seem to work properly either:[code]
I'd like to know how to compare one array to another array with objects.
For example:
Array1 = [one, blue, car]; // there will always be only one entry in this array - no Array1[1], no Array1[2], etc. Array2 = [product.number, product.color, product.type, product.cost, product.qty];
The actual content in Array2 would be something like this:
Array2[0] = [three, green, boat, 100, 5]; Array2[1] = [two, blue, truck, 200, 3]; Array2[2] = [one, red, car, 50, 20]; ...and so on, up to about 60.
I'm trying to figure out to go through all of Array2 to determine if there's a match to Array1. Since none of the entries in Array2 are the same, there will always be one match.In this instance, I want to match array1 with product.number, product.color, and product.type. My example has them as the first 3 criteria, though that may not always be the case.
Something along the lines of this:
Code:
function findMatch () { for(i = 0; i < Array2.length; i++) { if(all 3 Array1 items equals items in Array2[i]) {
[code]...
Background: I've a combobox search that allows a user to select from drop-downs. After a user selects items from all 3 drop-downs, they click a submit button, and there's a check to see if the criteria in the drop-downs matches anything in the Array2 (which it should, if you can select it, then it's in the array).
After that, the matched information is used to populate a movieclip. There's actually about 20 pieces of information associated with each product. However, I only need to match 3 of them.I've searched and found comparisons for arrays. But I don't see how they'd apply to my issue as I'm using objects and there are more items in array2 than in array1. Of course, they may apply, and I'm just not understanding how. I could create a 3rd array and move only the items needed for a match from the array2 to it. Then I could do a straight comparison between array1 and array3.
I'm working with 2 global variables and I need to compare them on 6 different button function clicks for a lot of different scenarios.[code]My function is starting to look like this;[code]only problem i see is that there are many different scenarios and this if statement could get very long. Is there a way to combine it somehow so there wouldn't be that many else if's?
Obviously the two date objects are somehow subtly different, and that difference somehow gets overlooked when they're parsed out as strings, but how are they different?
Is there a way of exporting an FLA file to a human-readable format, so that different revisions of a file can be compared?
I found a script for exporting to XML here (post 6):[URL] -- but it doesn't work as advertised - e.g. it doesn't export any details of items in the library.
I'm trying to position an image on top of another image based upon the make-up of the smaller image. The smaller image is a cut-out of a larger image and I need it to be positioned exactly on the larger image to make it look like a single image, but allow for separate filters and alphas to be applied. As the images are not simple rectangles or circles, but complex satellite images, I cannot simply redraw them in code. I have quite a few images and therefore do not feel like manually finding the position of each image every and hard setting them manually in actionscript. Is there any way for me to sample a small 5-10 sq. pixel area against the larger image and set the x and y values of the smaller image if a perfect match is found? All the images are in an array and iterating through them has already been set, I just need a way to sample and match pixels. My first guess was to loop the images pixel by pixel right and down, covering the whole bitmap and moving to the next child in the array once a match was found, leaving the matched child where it was when the perfect match was found.
I am starting to think I am going crazy. This function works perfectly until it reaches a condition of True, Then if fails. [code]When it becomes true it stops dead in its tracks and returns the following error message.[code]
if i have 2 arrays let us say: array1 = ["a", "d","f","j","g","s","o"]; array2 = ["a","b","n","f","k"];
Let us say i need to check the availability of each item in array2 into array1 and i want to delete it from array1. so if "a" is in array1 and array2, i wanna know that and i wanna delete it from array1.
I have a movie clip called "colors" that contains five clips (squares of different colors). I want to see only one of those colored clips at a time and I want them to be chosen at random (which i've accomplished). I would also like to make sure the same clips isn't selected again until all the other clips have been selected. On frame 1, I set up each main clip as a class:
function clipsClass(){} clipsClass.prototype = new MovieClip; clipsClass.prototype.onLoad = function(){ pickClips(this); } Object.registerClass("colors", clipsClass); [Code]....
Im trying to comapre the order and value of two arrays...
[Code]...
The values must be identical by the order and values exp: checkNums[0] == checkBallPress[0]; ps: the array numbers are inputed by user, I typed this values just for the examples sake I tried to do a nested for loop but it doesnt work.
For login I need to compare two variables. One of the variables (passw) is loaded dynamically. The other one (pw) is set by a form the user hast to fill. I wrote the following code on a button in the frame where the user hast to type his password (passw is already loaded from a textfile):
on (release) { if (pw == passw) { gotoAndStop(4); } else { gotoAndStop(3); }}
In frame 3 I wrote: "wrong password", code is stop () In frame 4: "welcome user", code is stop() I tried half an hour to fix that but I always get "wrong password". One more question: is a movie loaded with loadMovie(...) able to work with variables set in the main movie (in which I loaded it)?