ActionScript 2.0 :: Loop Through An Array Where The Indexes Are Literal?
Aug 17, 2003
Code:
ahmed = []
ahmed["a"] = "sdf"
ahmed["b"] = "asd"
trace(ahmed.length) // outputs 0
[Code]...
a) Why does the first piece trace 0 instead of 2?
b) How would i loop through an array where the indexes are literal (not numbers)
View 6 Replies
Similar Posts:
Feb 18, 2012
so i have an array containing many instances. let's say movieclips.
and i have another array which contains numbers..in this case those numbers represent selected indices that i've somehow chosen!
var manydots:Array = new Array ();
for (var i=0; i<10; i++)
{
var newDot:dot = new dot ;
manydots.push(newDot);
}
var indices:Array = [0,1,5,8,4]
i want to use AddChild to add those movieclips into my scene, but not all of them, only selected indices contained in my 2nd array
View 2 Replies
Jun 2, 2010
I don't seem to be able to find some info regarding this problem of mine anywhere...I would like to be able to access multiple values in an array.Let say I have an array with the index values 0, 1, 2, 3, 4, 5, 6, 7.These values will in reality be posts of htmltext for a news section - contained in an external xml-file.I would like to access these "values" like so:0, 1, 2 and then if you click a forward button the next three indexes 3, 4, 5 & so on. There will also be a back button with reverse functionality. I'm guessing a for loop?This loads the correct indexes the 1:st time.[code]...
But my problem is when clicking the buttons - how do I add and subtract from the var i? The problem is also when reaching the end & there might be just a single post or so instead of 3 - how can all of this be solved? Or does anyone now of a tutorial similar to my problem. I've found some tutorials but they only deal with one post at a time...
View 2 Replies
Mar 7, 2012
This is a somewhat modified excerpt of code I'm trying to implement:
Code:
public class View extends Sprite
{
[code].....
View 6 Replies
Nov 4, 2007
im having difficulties calculating the distance between array indexes. for example:
Code:
chararray = new Array(" ", "_", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
this is my array... and now i want to calculate the distance between 'X' and ' @'. This should be 6. How should this be calculated?
View 5 Replies
Apr 30, 2009
Is there a way to do something like this?
PHP Code:
var myArray:Array = new Array(10)
myArray[8, 9, 10].visible = false
where myArray[8, 9, 10] would access the last three objects referenced in the array?
View 6 Replies
Dec 9, 2011
In my code I need to declare notationArr1 but I'm getting this error: Error #1010: A term is undefined and has no properties.[code]
View 1 Replies
Feb 3, 2004
First a fabric button sets:
_root.fabricbuttonselected="_root.fabric01";
then the color button sets:
_root.selectedcolor=_root.fabricbuttonselected + "_chip10_name";
This returns the name of a variable:
"_root.fabric01_chip10_name"
however I have preset the variable to "Rose"
_root.fabric01_chip10_name = "Rose";
My dynamic text box is set to:
_root.selectedcolor
but instead of displaying "Rose" it displays"_root.fabric01_chip10_name" Basically I need to get the literal value to equal an expression- how do I do this?
View 6 Replies
Feb 3, 2004
[Code]...
My dynamic text box is set to: _root.selectedcolor but instead of displaying "Rose" it displays"_root.fabric01_chip10_name" Basically I need to get the literal value to equal an expression- how do I do this????? I've done this before, but it's slipping my mind.
View 6 Replies
May 19, 2011
In PHP you can do something like this:
Array1 = 0,0,3,6,6,6,7,8,8,9
Then loop through Array1 and set the keys of Array2
Array2[0] = true;
Array2[3] = true;
Array2[6] = true;
Array2[7] = true;
Array2[8] = true;
Array2[9] = true;
Array2.count = 6;
But doing a similar thing in AS3 would result in a count of 10 (true,,,, true,,,, true, true, true, true) as all of the keys that are not set are counted. Is there a way of doing this without using any more loops? or Functions, simplicity and efficiently are important here.
View 1 Replies
Feb 10, 2010
I've created a custom class to represent a monster in a game. The class definition has "public class Monster extends Object". I'd like to know if there's a way to initialize the object using object literal notation. For example, this works ok:
[Code]...
I get this error: "Implicit coercion of a value with static type Object to a possibly unrelated type Monster." Is there a way to do this? I'd rather NOT have to call the Monster's class initializer each time, because in the actual code there are a lot more variables in the monster class than just those three, and it's kinda unwieldy to pass a dozen long strings into the new() function.
View 3 Replies
Dec 28, 2008
I have copied some code from a tutorial only I seem to be getting problems with strings whenever I use newlines. Even putting:[code]Does this mean that in CS4 that newlines in strings are not allowed? I've also tried concatenating the string lines together using += but that didn't work and was tedious. Also, adding to the end or start of lines doesn't seem to work.
View 7 Replies
Apr 4, 2011
I have a class that holds some constants and will receive an object literal (associative array) with some data like this:
var ConfigObj:Config = new Config({
"Some" : 10,
"Other" : 3,
"Another" : 5
});
The class looks like this:
public dynamic class Config
{
static public const SomeProperty:String = "Some";[code].....
View 2 Replies
Oct 20, 2003
Scene=Scene 1, Layer=Layer 2, Frame=1: Line 10: String literal was not properly terminated this.pathToPics = "c:flashpics";
it said not properly terminated
View 4 Replies
Feb 9, 2009
I have to reverse the display order of a number of MovieClipsin a container. Somehow I cannot figure out how to do this as whenI use a loop construct and count through all Children I will always"pre"-alter the Indexes of the children still to come.
View 1 Replies
Aug 5, 2009
I just have another really quick question about Arrays, this time about Sorting them. I have just re- written my code to work for matching values from 2 arrays and then adding them to the screen.
however it seems as my matching is way off, it matches the items that are at the same index, which is not always the case
The output for the matches, which should be side by sideis as follows (which is incorrect) Therfore i am trying to find values at diffrent index levels
DunlopbabolatWilsonwilsonHeaddunlopAdidasheadBabolatslazengerSlazegerprincePrincevolklVolkladidas
I tried to sort the Array, but it seems as though the array, cannot be sorted the way i want it. I simply wanted to sort it Acending, but changing it to lowecase would not do what i needed it to do.
This is the code, matchInfo function should do all the work
package {
import flash.display.*;
import fl.transitions.*;
import fl.transitions.easing.*;
[Code]....
View 8 Replies
Aug 30, 2011
I have a TLFTextfield, which I've applied a TextFormat to, using a start and end index so it only applies to a range of text.Something similar to this:
var textfield:TLFTextField = new TLFTextField();
textfield.text = "Some Text";
textfield.textColor = 0x0000FF;
[code].....
View 2 Replies
Sep 30, 2009
I am looking at "length" property in the Adobe AS3.0 language ref as I do not understand it. It says: An integer specifying the number of characters in the specified String object. (I understand this). Because all string indexes are zero-based, the index of the last character for any string x is x. length - 1. (I do not understand the "- 1". I understand that all string indexes are zero-based but I cant put this together with the last character for any string being -1 or whatever it is saying.
View 7 Replies
Sep 25, 2009
I want to loop through an array and use the array value to reference a variable.
The Setup:
(For illustration only. Not actual script)
My MCs:
triangle_mc
square_mc
[Code]....
View 1 Replies
Aug 25, 2011
ActionScript Code:
var answerArray:Array = ["3", "2", "5", "3", "2"]; //these are the correct answers
var answeredArray:Array = ["3", "1", "1", "3", "2"]; //this is an example of what the user
[code]....
View 3 Replies
May 25, 2009
I am currently designing a website and creating a simple mp3 player with an on / off function but doesn't appear to be working. I am getting this error: 1095: Syntax error: A string literal must be terminated before the line break.1083: Syntax error: end of program is unexpected.1084: Syntax error: expecting rightparen before end of program.1084: Syntax error: expecting rightparen before end of program.1084: Syntax error: expecting rightparen before end of program.1084: Syntax error: expecting rightparen before end of program.
I have uploaded a zip file containing the images and FLA file. I'm wondering if someone wouldn't mind taking a look for me and telling me how to fix this problem: [URL]
View 4 Replies
Jan 20, 2011
I have this flash movie I've been working on for awhile. I've received in these forums. I have my file set to load an array of swfs. Now, though, I'm wondering how to keep it from looping. At the end of the last swf, I want the movie to go to the last swf and then just stop. Here is my code:
[Code]...
View 9 Replies
Nov 11, 2009
I have this map I'm creating in Flash. You click on a state, then you can click on an icon to view a tooltip/popup of some information. What I was trying to do was instead of creating new functions and event listeners for every different icon is to use a for loop...but it's not going so well.[code]...
View 2 Replies
Jun 21, 2010
I've a container file which loads an array of SWFs. The code is as follows:
var request:URLRequest;
var loader:Loader= new Loader();
stage.addChild(loader);
var myMovies:Array=["../flash/movie1.swf","../flash/movie2.swf", "../flash/movie3.swf"];
var movieNum:int=0;
var mcExternal:MovieClip;
[Code] .....
This works fine - the array is loaded and plays through once... What changes are needed to get it to loop through the array.
View 2 Replies
Oct 6, 2010
how can i set an array by using a loop.. the array is contains by a data that i read from database.. so the length of carry depend of the length of data in my database..
i try to use
for (var i:int = 0; i < xxx; i++) {
products = [p[i]];
}
i never read data from database in as3.. so if i want to use the data in database for this loop,what should i do?
View 2 Replies
Feb 16, 2008
if you could run a loop in an array?
I'm having to make an array that has each value increase by a 10, like 10, 20, 30, etc. is there an easier way to put in those values without adding them 'manually'?
and I have another question that is related. For this same project, on the stage there will be a text box and the user will put in a number--how can that value be run through the array? like say I input the number 500, how does it find it in the array? is there a passed id, a listener and a broadcaster?
View 2 Replies
Apr 29, 2009
i got stucked in a problem in actionscript 2.0
there is a 2d array - arr[12][13]
how can we start a loop to copy the value(using for loop) in manner:
a1=arr[0][0]
a2=arr[0][1]
a3=arr[0][2][code].....
View 5 Replies
Sep 15, 2009
I have an array like this:
Code:
var myData = new Array();
myData["name"] = "John";
myData["Age"] = 35;
What is the syntax to loop through and get the key and value? I have tried for each and for in but they just give me the value of "John" or "35", how can I get the key e.g. "Name" and "Age"?
View 2 Replies
Feb 8, 2012
Is there a simple equivalent to what I used to do in AS2 to add a bunch of new objects to the stage and throw them into an array so they can easily be referenced? I'm finding this more difficult than it used to be.
Old code:
ActionScript Code:
mc_array = new Array();
for(i=0;i<5;i++){
[code]....
View 6 Replies
Jan 29, 2009
Consider an array with x number of elements (of type Object) where some of the elements might be undefined.I use a for-each loop to access all the elements of the array that is not undefined (since it simply skips the undefined elements).But I also want the index of that particular element.The only option I can see is to use indexOf(). But it feels a bit like looking for water on the other side of the river so to speak.
When looping through long arrays each frame, is there a change indexOf() might slow it down? or does the for-each loop somehow know what index it's dealing with?
View 19 Replies