Arrays: Searching An Array In Flash... Syntax?
Trying to do something like PHP where you can take a value and search an array for that value. How can I do this without a loop?
DevShed > Flash Help
Posted on: January 13th, 2005, 10:13 AM
View Complete Forum Thread with Replies
Sponsored Links:
Searching Arrays
hello, i need to search a very large array and then return the index position in which the item was found.
is there a method i can use to do this?
something like: myArray.getPos(searchItem)
... or do i need to manually code a search loop? It seems like writing a binary search would be reinventing the wheel.
advice anyone?
thanks
View Replies !
View Related
Searching Arrays
What I'm wanting to do, is to have an IF function that checks if something is inside the array.
For instance, the the Array contains CHEESE, POTATOES, SAUSAGES
So, in the IF function, it checks if there's CHEESE in there somewhere.
Another bit of code would check if there's EGGS in there - and then it would run some code of it's own.
In summary, an IF function that searches through an Array for a certain expression.
Any help?
View Replies !
View Related
Searching XML, To Arrays
Hi all,
I'm trying to search through xml data and then load the inforamtion into seperate arrays. Below is the xml I'm searching and I want to collect it in red_arr, blue_arr and green_arr
Code:
portfolio>
<red>
<image>red1</image>
<image>red2</image>
<image>red3</image>
<image>red4</image>
<image>red5</image>
</red>
<blue>
<image>blue1</image>
<image>blue2</image>
<image>blue3</image>
</blue>
<green>
<image>green1</image>
<image>green2</image>
<image>green3</image>
</green>
</portfolio>
Here is my Actionscript
ActionScript Code:
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
if (success) {
searchXML();
} else {
trace("xml not loaded");
}
};
blue_arr = new Array();
red_arr = new Array();
green_arr = new Array();
my_xml.load("colors.xml");
function searchXML() {
var start = my_xml.firstChild.childNodes;
for (var i = 0; i<start.length; i++) {
var allxml = start[i];
if (allxml.nodeName == "blue") {
blue = allxml.childNodes;
for (var n = 0; n<blue.length; n++) {
blue_arr.push(blue[n].childNodes);
trace(blue_arr);
//trace(blueValue);
}
}
if (allxml.nodeName == "red") {
red = allxml.childNodes;
for (var j = 0; j<red.length; j++) {
red_arr.push(red[j].childNodes);
trace(red_arr);
//trace(redValue);
}
}
if (allxml.nodeName == "green") {
green = allxml.childNodes;
for (var k = 0; k<green.length; k++) {
green_arr.push(green[k].childNodes);
trace(green_arr);
//trace(greenValue);
}
}
}
}
This works fine up to now, but the arrays are
Code:
red1
red1,red2
red1,red2,red3
red1,red2,red3,red4
red1,red2,red3,red4,red5
and I just need
Code:
red1,red2,red3,red4,red5
Also can anyone see a better way to do the actionscript, I dont know if its to repetitive, could I do this with two loops.
View Replies !
View Related
Searching XML, To Arrays
Hi all,
I'm trying to search through xml data and then load the inforamtion into seperate arrays. Below is the xml I'm searching and I want to collect it in red_arr, blue_arr and green_arr
Code:
portfolio>
<red>
<image>red1</image>
<image>red2</image>
<image>red3</image>
<image>red4</image>
<image>red5</image>
</red>
<blue>
<image>blue1</image>
<image>blue2</image>
<image>blue3</image>
</blue>
<green>
<image>green1</image>
<image>green2</image>
<image>green3</image>
</green>
</portfolio>
Here is my Actionscript
ActionScript:
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success) {
if (success) {
searchXML();
} else {
trace("xml not loaded");
}
};
blue_arr = new Array();
red_arr = new Array();
green_arr = new Array();
my_xml.load("colors.xml");
function searchXML() {
var start = my_xml.firstChild.childNodes;
for (var i = 0; i<start.length; i++) {
var allxml = start[i];
if (allxml.nodeName == "blue") {
blue = allxml.childNodes;
for (var n = 0; n<blue.length; n++) {
blue_arr.push(blue[n].childNodes);
trace(blue_arr);
//trace(blueValue);
}
}
if (allxml.nodeName == "red") {
red = allxml.childNodes;
for (var j = 0; j<red.length; j++) {
red_arr.push(red[j].childNodes);
trace(red_arr);
//trace(redValue);
}
}
if (allxml.nodeName == "green") {
green = allxml.childNodes;
for (var k = 0; k<green.length; k++) {
green_arr.push(green[k].childNodes);
trace(green_arr);
//trace(greenValue);
}
}
}
}
This works fine up to now, but the arrays are
Code:
red1
red1,red2
red1,red2,red3
red1,red2,red3,red4
red1,red2,red3,red4,red5
and I just need
Code:
red1,red2,red3,red4,red5
Also can anyone see a better way to do the actionscript, I dont know if its to repetitive, could I do this with two loops.
View Replies !
View Related
Comparing / Searching Arrays.
Greetings. Let me first say this is my first post, and I did search the forum and I found a great explenation on how to find a value in an array, but my problem is a little different and I'm not smart enough to figure it out on my own.
I have a random picture-script that, not surprisingly, shows random pictures.
Basically I have one array with all the imagenames which i shuffle every time the image is going to change.
Code:
pic_arr = ["images/1", "images/2", "images/3", "images/4", "images/5", (.....) "images/55", "images/56", "images/57"];
And one array that keeps track of every image that has been displayed.
Code:
function shuffle(a,b){
return random(2);
}
pic_arr.sort(shuffle);
holder_mc1.loadMovie(pic_arr[0]+".jpg");
i = folder.length;
folder[i] = pic_arr[0];
So after the image has changed a three times, the folderarray looks something like this.
Code:
folder = ["images/21", "images/12", "images/43"];
Now I need a script that will select a value from pic_arr that ISN'T a value in folder. I've tried for a few days now but I've gotten nowhere.
Please help?
Thank you in advance.
View Replies !
View Related
Searching For An Array
Hi,
What is the code to search for an array?
I have the following code for the username and passwords:
myMultiDimensionalArray = [["Name",'name2'],["pass","pass2"]]
But need to know how to search for that in the Submit button frame.
Anyone know the array to do that?
Thanks!
View Replies !
View Related
Searching For An Array
Hi,
What is the code to search for an array?
I have the following code for the username and passwords:
myMultiDimensionalArray = [["Name",'name2'],["pass","pass2"]]
But need to know how to search for that in the Submit button frame.
Anyone know the array to do that?
Thanks!
View Replies !
View Related
Searching Within An Array
hello all,
quick lil question....
I'm trying to fugure out the best approach to to search within items in an array...
Here some sample code I use for basic (single item) search:
Code:
// Create an array with eight elements.
myArray = ["a", "b", "c"];
// Specify what we want to search for.
searchString = "b";
// Use a for statement to loop through, potentially, all the elements of the array.
for (var i = 0; i < myArray.length; i++) {
// Check whether the current element matches the search value.
if (myArray[i] == searchString) {
// Do something with the matching element, if necessary. In this example, display
// a message in the Output window for testing purposes.
trace("Element with index " + i + " found to match " + searchString);
// Include a break statement to exit the for loop once a match has been found.
break;
}
}
Ok, so what if I wanted to search for a Word among multiple words.
For example, how would I find out if the array finds a match within an array such as:
Code:
myArray = ["Betty Davis", "Team Macromedia", "Houston Soccer Team"];
How would I find all array items that match "Team"?
Your help would be greatly appreciated.
Regards,
jc_
View Replies !
View Related
Searching An Array?
Hey, the following code is from a Kirupa Tutorial, but i was wondering if there was a way of checking once an item is found in the array, where it is located in the array.
ie 20 is coOrdinates [0];
coOrdinates = new Array ();
coOrdinates.push (20, 21, 22);
contains = function (input, coOrdinates) {
for (i=0; i< coOrdinates.length; i++) {
if (coOrdinates[i] == input) {
return 1;
}
}
return -1;
};
if(contains( 20 ,coOrdinates)==1) {
trace("I'm here");
View Replies !
View Related
Searching Within An Array
hello all,
quick lil question....
I'm trying to fugure out the best approach to to search within items in an array...
Here some sample code I use for basic (single item) search:
Code:
// Create an array with eight elements.
myArray = ["a", "b", "c"];
// Specify what we want to search for.
searchString = "b";
// Use a for statement to loop through, potentially, all the elements of the array.
for (var i = 0; i < myArray.length; i++) {
// Check whether the current element matches the search value.
if (myArray[i] == searchString) {
// Do something with the matching element, if necessary. In this example, display
// a message in the Output window for testing purposes.
trace("Element with index " + i + " found to match " + searchString);
// Include a break statement to exit the for loop once a match has been found.
break;
}
}
Ok, so what if I wanted to search for a Word among multiple words.
For example, how would I find out if the array finds a match within an array such as:
Code:
myArray = ["Betty Davis", "Team Macromedia", "Houston Soccer Team"];
How would I find all array items that match "Team"?
Your help would be greatly appreciated.
Regards,
jc_
View Replies !
View Related
Searching Through An Array
Okay,
I have hit a dead end.... I have a quiz that randomly calls a question and then stores that question in an array called 'used' so that it isnt called again. I am trying to make a loop that searches through the 'used' array and only selects a question that isnt in that array. is there a way that I can select the range of the array, as in used[0-25]? What I have is something like this:
Code:
while( x = used[i]){
i++
}
This doesnt work though because it only searches the current spot on the array.... What is the best way to go about doing this?
Thanks so much in advance.
View Replies !
View Related
Searching An Array.
is there a function within the array class that does something like the vector class in java? well the function would work like this.
//pseudo code <>
function search(array , item){
var position = array.search(item);
return position;
}
//example ouput
3;
//meaning the item is in the position 3..
//pseudo code </>
is there any way to do that?
View Replies !
View Related
Fast Array Searching
I'm building an AS cache for SCORM data that stores info in a multidimensional array: [element name][element value].
The normal method to search this would be something like this:
code:
for (var i:Number=0; i<array.length; i++) {
if (array[i][0] == "someelementname") {
return array[i];
break;
}
}
Q1: Is there a faster / more efficient way to search the array?
Q2: If I'm going to add a 3rd property, a bit indicating whether or not the cache element has been committed back to the LMS or not, am I better off creating a class of objects or classes (e.g. write a cmi data element class: array[1] = new DataElement(score,200,0)), rather than using a multidimensional array?
The goal of this is to be efficient to eliminate lag between requesting data from the SCORM API and to prevent multiple SCORM API calls from being fired in a row by a developer, because ExternalInterface occasionally hiccups if that happens.
View Replies !
View Related
Searching XML Array Dynamically
I want to load an xml put the values on an array its just 2 values per node
then i want to be able to search the array dynamically, meaning to search as you type something like with .onChanged();
can someone tell me in what direction to go
i need to know how to use indexOf(); or another better solution to do this
using Flash cs3
View Replies !
View Related
Searching Array Elements
Hi,
I am trying to execute a condition to see if a particular value is an element of an array. say something like
if(a== elementOf(idArray)) {
trace("yes");
}
Is there a way to do the above or the only way is to code it to search through the array. Kindly pour in some ideas...
Thanks,
jay
View Replies !
View Related
Searching In Array With Objects
Hello everybody,
Let's say I have some objects:
Code:
var apple = new Object();
apple.taste = "acid";
apple.color = "red";
var berry = new Object();
apple.taste = "acid";
apple.color = "purple";
//more fruits
var myArray = new Array(apple, berry, fruit1, fruit2, ...)
Does anybody have an idea how to search the strings in the array? Let's say the user types "ci" to the search field, searching in "taste" (it would be marked). Now it should return the objects which have the string "ci" in the taste, as:
apple - acid - red
berry - acid - purple
...
I would really appreciate any ideas, advices, tutorials, codes, simply ANYTHING! Thanks a lot!
Poco
View Replies !
View Related
Searching An Array For A Character
I made a drag and drop interaction. I have 10 drag movieclips (drag1_mc - drag10_mc) and 10 targets (target1_mc - target10_mc).
I have a score array (score_Array) that keeps track of the placement of the drags on the targets (“C” if correct, “W” if wrong or dropped on an area on the stage other than any of the targets (also a drop with a collision with a drag already on a target) will set a “W” in the array for that drag and the drag will move back to home).
The array works great.
I am having a problem with a string variable to tell me if there are any W’s anywhere in the score array.
The following code works if I place the drags in the correct targets from 1 – 10
1-9 (C,C,C,C,C,C,C,C,C,W) will still show the scoreStatus variable as “Wrong”
checkscore = function(){
for (i=0; i<scoreArray.length; i++) {
if (scoreArray[i] == "W"){
scoreStatus = "Wrong";
}else {
scoreStatus = "Correct";
}; // end of if statement
}; // end of for statement
trace("scoreStatus = " + scoreStatus);
}; // end of function
Once I hit 10 it switches to “Correct”, but if I move a drag to an incorrect place it still shows as “Correct” even though the array now shows a “W” in the elements. The array works good, just the method to determine if any elements in the array is a W is flawed.
If I move correctly place just drag 10 from the beginning (W,W,W,W,W,W,W,W,W,C) it will show “Correct”.
I need a way to search an array’s elements and determine if the string “W” equals any of the arrays elements and if so the variable scoreStatus will be “Wrong”, else “Correct” (all C’s no W’s).
I just could make a lengthy if statement: if((scoreArray[0] = =”C”) && ( scoreArray[1] = = “C”) &&…)) but I would like it to dynamically use the scoreArray’s length as the iteration statement (the assessment might only have 4 drag clips)
So that’s in a nutshell: take an Array called scoreArray with elements (C,C,C,C,C,C,C,W,C,C) and figure out that there is a W in there and make the scoreStatus:String = “Wrong” or scoreStatus:Number = 1, just something that I can check easily whether you either got all the drags right or you got the assessment wrong.
Sorry this is so long…
View Replies !
View Related
Searching Array Elements
Hi,
I am trying to execute a condition to see if a particular value is an element of an array. say something like
if(a== elementOf(idArray)) {
trace("yes");
}
Is there a way to do the above or the only way is to code it to search through the array. Kindly pour in some ideas...
Thanks,
jay
View Replies !
View Related
Arrays And Syntax
I am new to action script, but came accross this in box with no explanation..
FillArray = new Array();
// this will create a new array called fill array.... fine i understand that
FillArray.push({x:x,y:y})
i know the push method push items into a array like
eg Myarray = new Array()
Myarray.push("Cat","dog","snail")
and then Myarray[0] = Cat...... I think...
But FillArray[0] is what?
what are these {} i though each item is separated by a comma so FillArray[0] = the x:x... however it doesnt and x was set earlier in the program as the start point of a fill but i have never seen this syntax till now.... so confused....
Larry thanks i know i am slow like the snail.
View Replies !
View Related
Arrays Syntax
Have a look:
Code:
for (j=0;j<artists[i].firstChild.nextSibling.childNodes.length;j++){
_root.totalCDs++;
artist_names[i][cdTitle[j]] = artists[i].firstChild.nextSibling.childNodes[j].attributes.title;
//item_mc.menu_item_btn.cdImg[j] = artists[i].firstChild.childNodes.attributes.image;
}
I'm trying to basically end up with:
artist[0].cdTitle[0] = some title;
artist[0].cdTitle[1] = second album name here;
artist[0].cdTitle[2] = thrid album name;
artist[1].cdTitle[0] = Thriller;
artist[1].cdTitle[1] = Dangerous;
etc...
BUT, assigning this "artist_names[i][cdTitle[j]]" doesn't seem to work. What am I doing wrong?
View Replies !
View Related
Searching For Matching Elements In An Array
Code:
myArray = ["a", "b", "c", "d", "a", "b", "c", "d"];
searchString = "b";
for (var i=0; i<myArray.length; i++) {
if (myArray[i] == searchString) {
resultsTextField = " Element '"+i+"' matched '"+searchString+"' ";
trace(" Element '"+i+"' matched '"+searchString+"' ");
}
};
I would like to display the search matches in the "resultsTextField", whether it's 2 matches or 20 matches, in the same way that they appear in the trace() output.
like this:
Element '2' matched 'b'
Element '4' matched 'b'
any ideas greatly appreciated.
N.B. script credits Joey Lott
View Replies !
View Related
Web Service Syntax ? And Arrays...
I'm calling a web service that returns an array. I have a function that just displays the result returned. I'm getting [object, object] when I trace the result. How do I pull a variable returned from the array like city? I've tried;
details.onResult=function(result){
trace(result.city); // equals undefined
trace(result); // equals [object, object]
}
please help;
what am i missing
View Replies !
View Related
Syntax When Dealing With Arrays?
Code:
this.ButtonContent.text = _root.menu1menu[0];
This works great, however I would really like to introduce something along the lines of this.
Code:
this.ButtonContent.text = "_root.menu"+var+"menu"+[0];
However, it's been forever since I've worked with arrays and I haven't a clue how to do this properly.
I thought eval might be an option, but that's very old school flash isn't it?
Thanks in advance
View Replies !
View Related
I Thought It Would Work But...(arrays & Dot Syntax)
Hey,
Well I've been trying to think of a way to create to scroll my images horizontally upon rolling over a button. Most of the solutions here talk about horizontal scrolling in relations to the mouse position.
So I thought I would create two MC and a button. The first MC is my menu with images(instance "menu"). The second is a blank mc with a loop(instance "initialize"). And the button starts my loop.
MC 1:
on clipEvent (data) {
Xpos=move;
Xmove=Xpos/10;
_root.menu._x=Xmove;
}
MC 2:
Frame 1 = stop;
Frame 2 =
for (go=0; go<10; go++) {
array[0]=(go+1)*10;
move=array[0];
_root.menu.loadVariables(move);
}
Button:
on (rollOver) {
_root.initialize.gotoAndPlay(2);
}
What I thought would happen was I would rollover my button; start the loop counting; have the loop assign a value to var move; and have the x position of my menu change as the new var move came into its AS.
Am I completely over my head?
Thanks.
View Replies !
View Related
Exact Syntax/arrays And Accessing Them
deck1 = new Array((whitemage, 1, 1, 2, 2));
cardname = deck1(1)(1);
i assigned a txt box the cardname var, it didnt show
why doesnt this work!?!?!
btw, i tried every variation, [] instead of () and "whitemage" instead of white mage, just to be sure
please help!
View Replies !
View Related
GetURL Syntax Problem With Arrays
i'm using the getURL(); function to open a link in another browser window but i'm trying to get the URL to be taken from an array,
i've tried things like...
Code:
getURL("linksArray[w][2]", "_blank");
and...
Code:
getURL(linksArray[w][2], "_blank");
but i can't get it to work. what is the syntax for something like this???
cheers
p.s. the url stored in the array is a fully qualified url e.g http://www.somesite.com
View Replies !
View Related
GetURL Syntax Problem Using Arrays
i'm using the getURL(); function to open a link in another browser window but i'm trying to get the URL to be taken from an array,
i've tried things like...
Code:
getURL("linksArray[w][2]", "_blank");
and...
Code:
getURL(linksArray[w][2], "_blank");
but i can't get it to work. what is the syntax for something like this???
cheers
p.s. the url stored in the array is a fully qualified url e.g http://www.somesite.com
View Replies !
View Related
Fuse-Syntax With Targets & Arrays
hello, i don't understand the syntax with arrays and fuse
in the documentation ist something mentioned, that i can use arrays with "fuse.addTarget" and "fuse.target"
Code:
var buttons_arr:Array = new Array ("b1_btn", "b2_btn", "b3_btn", "b4_btn");
var fuse:Fuse = new Fuse();
fuse.addTarget = buttons.arr; // don't work, which is the correct syntax here ?
thank for you help...
View Replies !
View Related
Advanced Actionscripters? Help, Please:dot Syntax, Referencing Arrays
Hello, once again. Thanks to whomever might be able to solve this...
Problem:
I have a movie in which I set two modes:
mode="one"
mode="two"
When in "one" mode, i have a clip which is duplicated into a containerclip (for reasons of maintaining control over depth).
"duplicateone" is the instance name of the clip being duplicated into "containone"
i reference it:
_root["contain" add mode]["duplicate" add mode]
when in "two" mode, i am doing the same thing, only with different clip being duplicated.
i reference it the same way, as mode is a global variable.
no problems thusfar...switching between the two of them is not an issue.
But now i need to be able to reference both of them, preferably with a single line. It's sort of like I've got the individual variable references to each instance working, but now I need to also have a 'global' variable that references both of them. If I can do this, it will mean management of the movie will be much easier, as will adding new modes...
So, I thought about setting an array of the modes...
and here's where it all fell apart....
I tried:
globalMode=newArray("one","two");
then i tried to reference it something like:
_root["contain" add globalMode]["duplicate" add globalMode]
and a couple of variations on it.
the movie explorer message tells me that an operand must follow my use of 'and'...
so, anyone know the syntax to address two clip instances using variables and/or arrays?
or, better still, any ideas on how i can get myself out of this predicament?
much appreciation to anyone who can offer insight...
thanks
View Replies !
View Related
Copying Array Inside Array Of Arrays
Hi,
I've got an array made up of other arrays, and I need to copy one of the arrays to a tempory array (so i can copy it)
I've tried using...
TempArray = ArrayList[0].splice();
but TempArray just shows (in debugger) as undefined, any idea's??
thanks
phil.
View Replies !
View Related
Array Syntax
I have some code that creates an array, then a variable that gives me the length of this array.
I am trying to get the last value that is in the array.
I don't think my syntax is correct
-------------------------------------
_root.lastvalue=_root.leefile[_root.arraylength];
-------------------------------------------------
_root.leefile is the array.
Thanks
View Replies !
View Related
Array Syntax
How can i store an array in a text file, and then reload it?
I have an php script that can save stuff to a text file and back, but normal actionscript syntax doesnt work when i try to use arrays
View Replies !
View Related
Array Syntax
Hello,
time ago I used
myArray = []
to define a new Array()
seems to me it would work like :
var myArray:Array = new Array()
But it doesn t since when I convert
myArray = []
with
var myArray:Array = new Array()
my old script doesn't work anymore
Any explanation?
Thanx
View Replies !
View Related
Is OOP Syntax Like An Array, Buckets, Or Both?
Let's say I have an object:
function favoritecd(number1, number2) {
this.firstcd = number1;
this.secondcd = number2;
}
After makin' an object,
bjork = new favoritecd("vespertine","homogenic");
I know I can access it's properties through dot syntax such as
bjork.firstcd equals "vespertine"
bjork.secondcd equals "homogenic"
but can I access the properties like so?
bjork[0] ----array style----
bjork[1]
or
bjork["firstcd"] ---hash/bucket style---
bjork["secondcd"]
View Replies !
View Related
Array Syntax Problem
ok, i have multiple arrays and i need to access them by using a variable that gets sent thru one of my buttons.
so let's say a button changes myVar to 0.
myVar = 0;
I need to set deptVar = to "advertising" which is held inside my array called "department".
deptVar = department[myVar];
so that much works. but now I need "advertising" to act as the name of the array I'm trying to call up.
so now that deptVar = "advertising", i want to call on the advertising array:
mediaType = deptVar[0][1];
i want the effect of it saying advertising[0][1] because there is no array called deptVar.
so my question is how do I use a variable like that to call up a different array?
I tried concatenating it like this:
newVar = deptVar + "[0][1]";
mediaType = newVar;
when tracing it, it looked right: advertising[0][1] but when i try to do something with it, Flash thinks it's a string!
can someone help my syntax??
thanks!
View Replies !
View Related
Syntax For Array Of Objects
Version: Flash MX 2004
Question: I'm trying to instantiate a class to an array. However, I can't figure out the syntax to make it work.
Here is what I used to generate an object:
Code:
var goodWeapon:CurrentWeapon = new CurrentWeapon("0","Food","100","-10","This is a test");
I'm trying to get something like this:
Code:
var goodWeapon[i]:CurrentWeapon = new CurrentWeapon("0","Food","100","-10","This is a test");
Thanks!
View Replies !
View Related
Array Syntax Problems.
I am having problems with my map array. I want the _global.currentmap to get the string from _global.maparray using the _global.mapx and _global.mapy which will be changed in my game when ever you leave the screen.
I think the bolded part is messed up, how would I make it work?
Code:
_global.mapx = 0;
_global.mapy = 0;
_global.maparray=["a1", "a2", "a3", "a4", "a5", "a6"],
["b1", "b2", "b3", "b4", "b5", "b6"],
["c1", "c2", "c3", "c4", "c5", "c6"],
["d1", "d2", "d3", "d4", "d5", "d6"],
["e1", "e2", "e3", "e4", "e5", "e6"],
["f1", "f2", "f3", "f4", "f5", "f6"];
_global.currentmap = _global.maparray[_global.mapy][_global.mapx];
View Replies !
View Related
Associative Array Syntax
I want to create an associative array, but using variables instead of hard coding.
example
instead of
assoc['field1']=data;
I want
assoc[fieldname]=data;
I've been reading for ages and cannot seem to find anything. I've tried the above and it doesn't work.
Any suggestions?
View Replies !
View Related
Loop & Array Syntax Help
I've got this loop and can't get it to work. It won't read the trace so I know the array call in my function statement is wrong but I can't see it at the moment. What am I doing wrong here? The rollover works when I write it out repetitively for the four buttons. Thanks for the help.
var btnAction:Array = new Array (oneBut, twoBut, threeBut, fourBut);
for (var i=0; i<btnAction.length; i++) {
this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() {
this._parent.btnAction[i].gotoAndStop("on");
}
};
View Replies !
View Related
Problems With Array Syntax
I need to assign a movie clip reference using the [] operators
I can do it in one assignation but not two, please help example below:
for (var i = 0; i<current_array.length; i++) {
var this_btn_name:String = "btn_"+current_array[i];
menu_open.empty_mc[i][this_btn_name].btn_index = this_btn_name;
menu_open.empty_mc[i]["."+this.btn_index].onRelease = function() {
// do frame change etc
}
}
the name of the button index references to names 1-4 etc so that it can pass that data on to a switch statement.
View Replies !
View Related
Array Prototype Syntax How To ?
I need a new array prototype function which does about the following:
----
array.prototype.NextSibling = function(){
return(this.NextSibling); // ??? possible ??
}
x=MyArray[0].NextSibling();
----
x shall now point to MyArray[1].
possible somehow without XML?
also, would be great to be able to locate a "parent" array within a function:
----
array.prototype.MyParent = function(){
return(this.Parent); // ??? possible ??
}
y=new Array ( [1,2,3] , 2, 3);
x=MyArray[0][0].MyParent();
----
x shall now point to MyArray[0].
View Replies !
View Related
Help With Syntax (array Access Operator)
Hi,
I am trying to address a ""clipC" + n " without "dot" operator and identifyier. The problem is, it lives in a clip whose name I can't write out either.
I tried this
--------------------------------------------------------
clipA["clipB"+n][clipC" + n].doSomething
--------------------------------------------------------
but to no avail. Can anyone help me with the syntax?
View Replies !
View Related
Values From An Array | Syntax Check
Howdy Amigos,
Give me a hand with a syntax check....
I'm plotting points out of an array and am trying to alter the "origin point" at which they are plotting...
Everything works great until I try to add a fixed value, so this syntax works great...
// iterate over array elements
for (i=0; i<(id.length); i++) {
// clone movie clip and name it
// clip.duplicateMovieClip("mc"+i,i, i);
duplicateMovieClip("mc0", "mc"+i, i);
// set position
setProperty("mc"+i, _y, yCoord[i]);
setProperty("mc"+i, _x, xCoord[i]);
_root["mc"+i].traptype = traptype[i];
_root["mc"+i].pestcount = pestcount[i];
// reset name values
setProperty("mc"+i, _name, name[i]);
stop();
}
But when I try to change the values of the x & y with simple math...
I would expect that this would work if swapped in, but it doesn't... i get no points at all...
set origin point
// this movie clip origin point for plotting is at x: 184 y: 70
// set position
setProperty("mc"+i, _y, yCoord[i] + 70);
setProperty("mc"+i, _x, xCoord[i]+ 184);
Ive also tried setting xOrigin = 184 and yOrigin = 70
and adding them as variable values, but again no dice...
Any ideas really apprecaited...
I'd rather not perform math on the arrays themselves, but on the individual variables being called from them...
Steve
View Replies !
View Related
Array.splice Syntax Problem
Ok, here's a question with the "array.splice" method. I have an array with each entry holding a pair of values.
What I want to do is swap out a single value of a specified entry in the array. As long as I'm not working with
pairs I'm able to do it fine, but I must be off with my syntax or something when doing pairs. Any assistance would
be much appreciated. Ok, here we go:
partLocations = new Array();
partLocations.push({x:46,y:82});
partLocations.push({x:46,y:70});
partLocations.push({x:46,y:58});
trace(partLocations[0].y);
trace(partLocations[1].y);
trace(partLocations[2].y);
trace("-");
partLocations.splice([0], 1, 200);
trace(partLocations[0]);
trace(partLocations[1].y);
trace(partLocations[2].y);
so you can see when I use the splice to change the ENTIRE entry in the array it does fine. As you can guess, the
trace returns the following:
82
70
58
-
200
70
58
I just took out the entire "0"-position entry in the array and told it to change to the value "200". But I just want
to change the specific "y" value in that entry... so I'm trying this:
partLocations = new Array();
partLocations.push({x:46,y:82});
partLocations.push({x:46,y:70});
partLocations.push({x:46,y:58});
trace(partLocations[0].y);
trace(partLocations[1].y);
trace(partLocations[2].y);
trace("-");
partLocations.splice([0].y, 1, 200);
trace(partLocations[0].y);
trace(partLocations[1].y);
trace(partLocations[2].y);
... hoping that it will return
82
70
58
-
200
70
58
But instead it just returns the following:
82
70
58
-
82
70
58
Can anyone see what I'm doing wrong?
Much thanks in advance.
Mike
View Replies !
View Related
Simple Array Syntax Question
I made an array of 10 items (mcs used for buttons) and these buttons are used to access pieces of work for separate clients in my portfolio and with each client, there are a varied amount of these buttons activated so I need to know how to activate, for example, array items 1-4, then deactivate 5-10 but I'm not sure how to access them in clusters that way. I know I could do it:
myArray[1].deactivate = true;
myArray[2].deactivate = true;
and so on... but there are several attributes being applied to these buttons and I'm sure there must be a simpler way of doing it. Can anyone help me?
View Replies !
View Related
Need Syntax For Defining An Array Of Names
Hello,
Can someone tell me the syntax for defining an array of names.
I will put in the values myself, like myArray["pete.swf", "laura.swf".....]
This array will be accessed later from a function in the same level.
So something like
_level0.myArray["pete.swf", "laura.swf"...]
and then,
name = _level0.myArray[i];
View Replies !
View Related
Array Activebtn Syntax Problem
Hey there gurus,
I'm creating a menu in the form of an array, and I've set up a movie variable that tracks the activated menu item. What I want to do is tell my menu to activate the next or previous item in the array. I haven't figured out the syntax, and would greatly appriciate any help. Here's a sample code:
//creat array of four items
var my_array:Array = [
{mc:thumb_one},
{mc:thumb_two},
{mc:thumb_three},
{mc:thumb_fou}
]
// activebtn tracks the currently selected button
var activebtn:MovieClip;
//if my_array[0].mc is the active button, make my_array[1].mc the new activebutton - THIS IS WHAT I CAN'T FIGURE OUT
activebtn= my_array[activebtn+1].mc
Thank you so much in advance for any help.
-Aaron
View Replies !
View Related
Array Shorthand Syntax Question
Hello everybody. I'm currently working on an Adobe AIR app that will manage inventory for a small company. It uses an SQLite database to store all the data... and my problem is not with getting the queries to work. I've been studying the code from the SQLite Admin program written by Christophe Coenraets. I wish I could have found an email address on his website, I would have asked him about this, since he wrote the code in the first place! Here's a link to his app.
http://coenraets.org/blog/2008/02/sq...in-for-air-10/
Anyway, here's the code I can't figure out.
Code:
var data:Array = result.data is Array ? result.data : [{rows: result.rowsAffected}];
The var result is a SQLResult object, and the query it runs (select * from table) returns rows as it should. I tried looping over result.data to make an ArrayCollection to populate a DataGrid with... but my code won't work.
Could somebody explain WTF is going on with the IS keword, the question mark, and the curly brackets INSIDE square brackets?! I can't find anything documenting this syntax online and it's driving me nuts.
View Replies !
View Related
|