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?
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)?
what's a simple way to combine arrays with as3? by combine, i mean that contents of one array are pushed into another array.I already tried a for loop and push.
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) {
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.
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.
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?
I have these movies already existing in my actionscript code: inner_mc AND gallery_mc.So - I attach my library movie clip: called "link_box", and name it link_box0 and so on through the loop.
-->
for (i=0; i<numimages; i++) { inner_mc.gallery_mc.attachMovie("link_box", "link_box"+i, i);
Now I want to create a new movieclip called thumbnail0 and so on, to the newly attached movieclip.
This is my attempt: this.movieHolder = inner_mc.gallery_mc.link_box+i.createEmptyMovieClip("thumbnail"+1, i+1);
When i try:trace(this.movieHolder ) it says undefined for all times it loops through.
Whats the syntax to combine strings and variables so that the result is seen as an object name ?
I have some script which grabs stuff from an xml file. The stuff grabbed from the xml is in a loop to create an automatic menu. This is all fine and dandy. Say there are 9 items in the xml file, I get 9 menu items with their unique id's.What I want to do is define an array for comparison against the info taken from the xml file. Say in the xml file I have nodes set up for Apple, Pear, Banana and Orange. With my current script I would get a menu with these items on it. What I need to do is be able to specify the items I want to appear on the menu. For this example I would want Apple and Banana only.
I have experimented with if statements, and it takes too much code to accomplish what I want I am sure there is a more compact way. My idea is to set an array with the items I want in it,then when the information is taken from the xml file,I need the script to do the function of creating menu items only with the items I have specified in the array. Below I have added the code, which has been modified from Kirupa's own squirrel finder tutorial.I need the code to be as reusable as possible, ie only the array would need to change.In my code the variable featureType would contain the information I need to compare against.
Code: //set limits on the features that need to display // define array var featureLimits:Array = ["Apple", "Banana"];[code].....
I'm having a problem with the supposed AI that I've created for a card game that I'm making. The purpose is to have the function meant for 'player 2' to run after the human player has put down a card. What the function is supposed to do is to compare the value of the card which is stored in a array, and then according to the value assigned the AI is supposed to compared with the 4 cards in its hand and decide on which is the best possible card to pick. Though the human player's code seem to work as expected, for some reason the function for the computer did not run and instead churned out a huge chunk of data in the output. I will attach 2 separate text files; one will include the portion of the code which I highly suspect is giving the problem, the second will be the supposed error message.
I'm trying to figure out the best way to compare a single bitmap against perhaps an array of saved bitmaps to see how close of a match it may be to any one of the bitmaps stored in the array. Right now I'm running a for loop that uses the bitmapData.compare() method to try to compare to see how much of a variance there is but... to be honest I'm at a loss as to how to use the resulting data to do so. Does anyone know of any good method to accomplish what I am trying to do? Forget looking at my code it's a waste of time because simply, it's not working.
How can I make a bunch of variables from a for loop. for example for (var i=0; i<total; i++) {var bunch(i);}. that i make a bunch of variables named bunch1, bunch2, bunch3. I keep getting errors. I program and use so many different languages that I dont know if that can be done with AS3. my only other alternative i can think of is to create some sort of event dispatcher object array. but I dont know how to get them all to send events to one listener with there index number.
I have a list of strings that I add to an array, then attempt to set those values in a for-loop using data that I read in. The array gets updated, but the values the array contains do not. I also have an array of buttons that I update this same way that works great, but strings don't seem to work the same way. I have tried moving the string array to give it full scope, and still nothing...
public class test extends Sprite { // Declare a list of strings protected var title0:String = undefined;
There is a bird, and you control its upwards movement with a key. It has thrust, gravity, it works fine. The problem is I have a bunch of icicles that come at the bird that he is supposed to avoid. I tried this first with math random to use as an x coordinate and than move across the screen, but the icicles had the same x-coordinates sometimes. I tried does not equal(!=) but that doesn't work. I made an array and each number that came out of the array I assigned a different variable. This works fine. I put this variable into the x-coordinate such as mc.x=((n)*60)+480. I did this for five different icicles. All their differnt variables have a different value, and I put them into the same function for each individual video clip, but they still don't go to the right coordinate. Here is the test code just for the initial coordinate of each icicle before it moves...////////////////////////////Quote:
var temp:Array = new Array() for (var i:int=0;i<8;i++) { temp.push(i);
I have some variables created on the main timeline and a mc called options which will be where those variables can be manipulated. A way I've tried to this is by creating a first array(array1) and populating it will all the variable names found on the main timeline, and another array(array2) containing the values of the variables the user has changed(which are displayed on some dynamic text fields). To make these changes, an "apply" button is pressed which will set the values found in array2 to the variables in array1.[code]How would you do this so that var1, var2... are updated properly according to the values found in array2?And because array2 contains strings(read from dynamic textfields), how do you deal with that since var1 and var2 are numbers?
Code: var positions:Array = new Array(Stage.width / 2, Stage.height / 2);
When the above code is executed, the values "Stage.width / 2" and "Stage.height / 2" are replaced with the number values and the array becomes, for example [500, 400].And when I call the array positions[0], instead of getting the value of the Stage.width / 2 (considering the stage has been resized), I get the static value of 500.What can I do to get the value of Stage.width / 2 ?
Why doesn't AS2 interpret these variable as it steps through? Everything works if I write it out longhand and do not use a loop, but if I try to condense things by using an array, variables such as _root.myTargets[i]._x are not interpreted properly.
Code:
myTargets = new Array('shoot','shoot2'); for (var i:Number=0; i<myTargets.length; i++) { if ((_root._xmouse > (_root.myTargets[i]._x - 30)) and (_root._xmouse < (_root.myTargets[i]._x + 50)) and
I think I am getting pretty close here but can anyone direct me in the right direction to be able to return the values in the array in a sequential order?
Code:
var twentythreeX:Number = 0; var unihiphopX:Number = -320; var unimetalX:Number = -760;
[Code]....
This is for a simple slide show just when the next button is pressed it will tween to those coordinates.
I have this code to push "Variable1" in to MyArray: ActionScript Code: _root.MyArray.push(Variable1); Note: "Variable1" is a number stored as a string. When "Variable1" changes, the code above is called upon to add the new "Variable1" value in to MyArray. Then I have this code which is called upon to find the sum of all the values within "MyArray":
My problem is that rather than adding the values contained within MyArray (as if they were numbers), the values are being concatenated instead.
Example: If MyArray values were 1, 2, 3 I want the MyArray_Total to = 5 But instead... MyArray_Total = 123
I tried making a new variable named "Variable1_num", declaring it as a number, making it equal to "Variable1", and then pushing "Variable1_num" in to "MyArray"... but that didnt seem to work either.
I am doing my first simple game using Flash CS5 and Actionscript 3.0. In this game the player would be able to create a new quiz where it would create an array and add sets of questions and answers to that array. I have been looking on how to do this or anything like it and it doesn't seem to be possible (at least in this way).
I'm interested to fill a simple array with variable names, NOT with strings! , because I need it for catching the data from asp file.I tried something like that but it doesn't work