ActionScript 1/2 :: Comparing Two Variables With If Statements

Jan 11, 2010

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?

View 3 Replies


Similar Posts:


ActionScript 2.0 :: Comparing Two Variables For Login?

Jan 16, 2003

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

View 3 Replies

ActionScript 2.0 :: Comparing Values From XML To Variables In Flash?

Dec 8, 2009

I've got an xml file that contains some data (which will be created by an external file later on in the project) and i want to be able to check the data in that XML file against a variable stored in flash.

If the value in the XML is equal to or greater than the value in the variable i want to jump to a different frame. If the xml value is less that the variable value i want it to stop and tell the user a message. i've included my code below. I just cant get it to work. Regardless of if the value in the XML file is higer or lower than the variable in flash, it always continues to the final frame instead of stopping accordingly.

ActionScript

Code:
//Load xml file that contains amount of cash user has and populate cash_txt box with amount
function loadXML(loaded) {

[Code]....

View 1 Replies

ActionScript 1/2 :: Comparing 10 Variables And Listing Top 3 On Scoreboard

Mar 22, 2010

I am making a scoreboard. On this scoreboard I will have 10 different scores. I want to compare the 10 scores and list the top 3 scores in another location. I was thinking at first
if(score1>score2&&score1>score3&&score1>score4 etc.....){
some function
}
But this will only give me the top score in the group. I would like to find the top 3 scores, and then list them.

View 4 Replies

ActionScript 3.0 :: Comparing Array Variables And Combine?

Aug 7, 2011

I'm trying to compare two array variables and combine if they do. This is what I have in mind: (it's inside a "for")

Code:
var people:String;
if (arr[i + 1][0]==arr[i][0]){
people = arr[i + 1][6]+", "+arr[i][6];

[code]....

The "i + 1" obviously do not work.

View 9 Replies

ActionScript 2.0 :: Comparing Variables Inside Functions To?

Jul 29, 2007

var q4:Boolean = false; //Will have thirty-eight of these, q4-q41

function noRepeat() {
if (q(_root._currentframe) == true) {
gotoAndStop(randRange(4, 41));
} else if ((q(_root._currentframe)) == false) {
q(_root._currentframe) = true;
}
}

Now, my problem is the bits in red (yes, I know they don't work, that was just the best way I could think to describe what I wanted).

If I create a string that says "q4" then I find it won't compare that to the boolean variable, but I'm positive there must be a better way than putting one of these on every frame.

View 2 Replies

ActionScript 3.0 :: Using Variables And If Else Statements?

Apr 19, 2010

used to be able to handle variables and if else statements back in AS2.0, but I don't know how to go around them in AS3.0For instance, a code like this:

stop();
var pageNum = 1;
var pageAnim = 1;

[code]....

View 7 Replies

ActionScript 2.0 :: If Statements Checking Variables?

Sep 16, 2005

I'm having the hardest time getting this to work, I have the concept of how things need to be put together, but the code is wrong. I can't even get the first if statement to work.I have a menu that is going to be loading external swfs into an empty mc. It needs to check to make sure the external swf has gone through its stopping animation before loading something else. Here's what I've got so far... I hope this is clear enough...button:

Code:
on (press) {
//check if this is the first mc being loaded

[code]....

View 6 Replies

ActionScript 2.0 :: Check Many Different Variables In Many Different MC's Without A Billion If/else Statements?

Sep 17, 2005

Is it possible to check many different variables in many different MC's without a billion if/else statements?

View 2 Replies

ActionScript 2.0 :: Randomly Creating Variables For If Statements

Jan 19, 2006

How can I randomly create some variables as the movie loads so I'll be able to use this variables as a if statement later on and make the movie play diferent labels?

View 4 Replies

ActionScript 2.0 :: If Statements Within If Statements?

Oct 7, 2004

If they get a question wrong in my quiz ( weakest link) the money clip goes to zero and it goes onto the next question. If they get it right the money clip advances and they go onto the next question. I want to include each time that it should only go onto the next question if all questions have been asked. SO i want an extra if clause in both sections, saying if current question is more than 11 go to '#game over"The questions are saved in the frame of the quiz

_root.qArray = new Array("question: A;B;C;D")
_root.qArray.push("Question?:A;B; C; D")

There are 11 questions.At the moment at the section with choosing answers I have

function selectAnswer(n) {
// correct
if (answers[n] == correctAnswer) {
_root.money.nextFrame();

[code].....

View 1 Replies

IDE :: Comparing The Two Lines?

Sep 2, 2009

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.

View 2 Replies

ActionScript 3.0 :: Comparing 2 Different Arrays

Apr 28, 2010

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?

View 8 Replies

Comparing Arrays And Loops

Nov 29, 2010

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.

[Code]....

View 4 Replies

Use .toString() - Comparing Array's?

Jun 30, 2009

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?

View 9 Replies

Comparing Two Numbers Not Working?

Jul 16, 2009

I am stumped. I can not figure out why this refuses to work.

Code:
function checkNumber():void{
if(currentCounter == totalImages){ currentCounter = 1; }

[code]....

View 6 Replies

Actionscript 3 :: Comparing ParseInt To NaN

Oct 18, 2010

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

View 3 Replies

ActionScript 3.0 :: Comparing The Two Bitmapdatas?

Jun 5, 2011

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.

View 3 Replies

ActionScript 2.0 :: Comparing 2 Versions Of A FLA?

Oct 8, 2006

Is there a tool that would allow you to compare the script in 2 flash files, and shows you the differences in both of them?

So actually a text file comparison? But perhaps adapted to Flash?

View 1 Replies

ActionScript 3.0 :: Comparing 2 Functions?

Sep 9, 2010

How can I compare 2 functions in AS3 ?

View 6 Replies

ActionScript 2.0 :: F8 Comparing To Multiple Strings

Jul 5, 2009

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]

View 3 Replies

ActionScript 2.0 :: Comparing Two Arrays (one With Objects)?

Apr 2, 2011

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.

View 2 Replies

ActionScript 3.0 :: Comparing Arrays When Both Has The Same Object?

Nov 3, 2009

I want to compare my two arrays.When both has the same object. they will trace out the name i give.This is the code;

var cap_array:Array = new Array(Sugar,Sugar,Milk,Cocoa);

function ingredients(evt:TimerEvent):void {    var ing_mc:MovieClip = null;    timer++;[code]......

There is no error in the code; but it can't trace out "cappuccino". Is it I should take the ingredients in order like in the array of the cap_array?

View 6 Replies

Flash :: Comparing Date Objects In As2

Jan 5, 2010

[Code]...

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?

View 1 Replies

Javascript :: Comparing Two Different Date Formats?

Feb 26, 2010

I have a 2 different date formats. 1) dd/mm/yyyy 2) dd-mm-yyyy

I want to compare these 2 date formats in Javascript or Actionscript.

View 3 Replies

Flash - Comparing/exporting FLA Files?

Mar 29, 2010

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.

View 4 Replies

Flex :: Comparing Hours And Minutes In AS3?

Jul 25, 2010

Is there a way to compare the current time to a bunch of times (loaded from XML) and have it figure out which is the closest to the current time?

View 3 Replies

Actionscript 3 :: Comparing Two Bitmaps Against Each Other For Match?

Mar 25, 2011

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.

View 4 Replies

ActionScript 2.0 :: Comparing The Array Elements?

Jun 25, 2009

I have one array with many elements inside.

ActionScript Code:
var all_id:Array = new Array ["56","42","35","64"];

I also have one cd id, which is dynamically created.Im trying to create a function, which checks if the cd id matches any of the IDs of the array.

ActionScript Code:
for(i=0; i<all_id.length;i++){
if(all_id[i] == id){
trace("ID MATCH");

[code]....

My problem is that - because I'm looping through the elements, I get several traces.Is there a way to get a result if any element matches?

View 2 Replies

ActionScript 3.0 :: Comparing Two Numbers Not Working

Jul 16, 2009

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]

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved