ActionScript 2.0 :: Make Arrays As Variables?
Dec 26, 2006
why cant the variable "height" modify the position of y? =S im new at ac so i dont know if an element of an array can be a variable? and how do i make it a variable?this is a par of the code im writing to make a group of movieclips appear offstage in a random positions as long as it is offstage (i know the array is not random since i give the values of each element but i tried by putting y= math.random * number?... but in the coordinates i didnt knew how to specify that it could be any random number exept the lenght of the stage)
onClipEvent (load) {
myArray = new Array ();
myArray[0]=-100;
[code].....
View 8 Replies
Similar Posts:
Jun 25, 2004
correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element.. My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.The hierarchy I want to create is as follows:
AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
AllBrigades [0] [2].push (MyUnit);
But when I trace this I just get undefined.
View 14 Replies
Nov 14, 2006
Hello all,
I am having some weirdness with arrays and variables. I'm sure this is something basic but I can't get it to work. I have a an MC name "circle" this also contains dynamic text field name nameMC. Writing to that textfield is simply circle.nameMC.text = "New copy";
So below I have two arrays.
Code:
var textArray:Array = [one, two, three];
var newArray:Array = ["one", "two", "three"];
for (var i:String in newArray) {
this.attachMovie("circle", newArray[i], this.getNextHighestDepth(), {_x:Math.random()*300, _y:Math.random()*200});
textArray[i].nameMC.text = newArray[i];
}
This doesn't work. I've tried swapping the various arrays but no luck. So why does the movieclip want to use the "quoted" array value and not the unquoted. Also, when I use"
Code:
one.nameMC.text = "hello";
everything works fine, but the arrays won't. So:
Code:
textArray[i].nameMC.text = "hello";
for example doesn't work.
Thanks for any guidance!
View 3 Replies
Apr 21, 2011
i want to choose one of these randomly, I have a loop way in which there is a loop searching for the index number which is inside an array like M1[1]=1 , M2[1]=2 and if I have a random number between 1 and 20 I can loop the arrays [1] element.
But is there another way with directly get the random array buy name. For example I have the random number 14 which directs me to M14. how Name of the array help me to choose M14 when I have the number 14....
View 2 Replies
May 4, 2009
After unexplainable problems with external class files, I'm trying another way of doing what I need to do: an Object variable declared in the fla file. Well, this has its own set of problems. The big picture is: I need to get user data and populate fields in their profile when they sign on. Then save changes to their profile during the session, add new users and make changes to their profiles. Pretty normal stuff.
Here's the problem I'm having with the object.
Frame 1 Script:
/* Define the object to use as an associative array.*/
var Person:Object = new Object();// Define a series of properties.Person.HomName = "Joe";Person.HomEmail = "joe@gmail.com";
Then go to a new keyframe, where I have my fields that need to be populated
Script:
EnterName.text = Person.HomName;EnterEmail.text = Person.HomEmail;stop();
When I compile, I get this error twice (once for each field) "The property being referenced does not have the static attribute."
What does the mean and how do I fix it?
Here is a link to the source file if you care to look.
[URL]
The only way I've been able to get variable data from one script to another is through a _global.variable. Is this the only way? No arrays or objects vars?
Thanks in advance for all who assist. Some day soon I hope to be able to return the favor!
View 3 Replies
May 17, 2009
- I tried, when I first started making this site, to load all of the artwork images into an array and then copy the array before resizing them for their specific functions (being seen as thumbnails or as full size pics.) Unfortunately, I ran into the well known issue of Array cloning only creating a pointer to the same group of items. I tried the newArray = oldArray.slice() trick, but it didn't seem to work. Finally, I just loaded the images twice into two separate arrays, and it works, but I hate this solution. Anyone got a better one?
- I'm trying to maintain some sort of connection between the two sets of Arrays so that, for example, when someone clicks on Thumbnail 15, Fullsize Image 15 will open up but I couldn't find anything that worked. Renaming the Instance Name dynamically didn't seem to work and adding an Instance Variable dynamically doesn't seem possible either as I can't make the Class I am working with (Sprite, in this case) dynamic ahead of time. I'm sure there's a simple method for this.opens up, the different animations seem to interfere with each other and slow each other down (they also seem to get interference from the time taken to load the image Arrays.)
View 9 Replies
Mar 8, 2012
I have a string variable that looks something like this:
2012-03-07 135.06 135.91 134.93 135.69 143616800 135.69
2012-03-06 135.35 135.43 134.36 134.75 202129900 134.75
It continues like this, a list of reoccurring variables seperated by spaces, for a few more lines.How can I separate the string and push the different variables into their appropriate arrays. The end result should look like this:
dates = [2012-03-07, 2012-03-06]
variable1 = [135.06, 135.35]
variable2 = [135.91, 135.43]
View 10 Replies
Jan 7, 2012
I have a piece of code worked out that creates circles on a mouseDown function. I'm trying to save the x and y cords of the circles but cannot figure out a way around this. I need to save multiple instances of the cords from mouseDown.
Is it possible to do this in an array?
var posOne:Number;
//var posTwo:Number;
//var posThree:Number;
[Code]....
View 2 Replies
Mar 31, 2011
I am trying to load variables from my webpage onto my .swf
ActionScript Code:
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, loading);
[code]....
This code works perfect for loading variables in a &var1=1&var2=2& etc...But how can I load variables from the page?like do I need to put in &array_name[incrementing_var]=value& and then when i go to access it it should be loader.data.array_name[0] but this doesn't work for me? I realize my URLLoaderDataFormat.VARIABLES is for variables but can i still pass arrays with this? or do i need a new format? or do i need to pass the values as variables and convert them into an array in my AS?
View 5 Replies
Feb 4, 2012
I have got the sound functionality working for two sounds in my embedded movie clip, each controlled by their own on-off button.I need to add this for another 20 or 30 sounds in the movie clip.I have the feeling there is a way of reducing the amount of code here using variables and/or arrays.
View 1 Replies
Jan 17, 2004
Say I made var $temp[] an array and put stuff into it, could i then redeclare temp as var $temp = 4 or maybe var $temp[], another array, but completly clear? or would it hold a risidual? If not is it possible to wipe an arrays content? In java we used to dump and drop variables all over the place, a string could be an integer, then a char, then a float or a double at a whim.
View 5 Replies
Dec 18, 2007
I'm trying to use associative arrays to store my variables but am looking for a solution to change the value of array1[i] to array2[i]. Since it's an associative array, the only way I know how to loop through these kinds of arrays is by the following:
Code:
for(var i in array1) {
trace(array1[i];
}
What I would do when using indexed arrays to change the value of array1[i] to array2[i] would be something like this:
Code:
for(i=0; i<array1.length; i++) {
array1[i] = array2[i];
}
However, I can't see any way you can do this with associative arrays because they do not have a numbered index such that in a loop you could
say array1[i] = array2[i] .
So I'm looking for a way to do this with associative arrays.
View 14 Replies
Feb 21, 2009
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.
View 5 Replies
Mar 4, 2012
Is there a way to make an mc switch arrays?
View 9 Replies
Oct 26, 2007
I'm trying to create something (which has probably been created a 1000 times before) that will fade in and out a series of images. I load the images into my movie and then I want to make some action script to loop through them to fadeIn/Out.So to begin with I want to store all the image names in an array and then loop through this. But I'm having problems accessing the movie clips from the array. Where am I going wrong?
Code:
var images:Array = new Array();
images = [wine_mc, sunset_mc, poppies_mc, pool_mc, eastView_mc]
[code]....
View 1 Replies
Jan 10, 2012
I have two arrays contains several movie clips. I used for loop to inject first array in timeline object succefuly. But then I realized, what the hack I will do about the second array I need to start them simultaneously and every array must have different destination at x and y.. Imagine banner 745x100px, I need to animate different movie clips from sides to some destination.
Code example:
import com.greensock.*;
import com.greensock.easing.*;
import flash.display.MovieClip;
var mainArray:Array= [amcMC, tantrumMC, blokMC, misMC, futMC, laoMC, cauMC, deepMC, plusMC, noMC, copMC ];
[Code] .....
I need to apply slightly different tweens on second array and trigger them simultaneously, or with small offset.
View 2 Replies
Nov 2, 2009
I retrieve XML data in Flex via HttpService. I have the resultFormat property on the HttpService instance set to HTTPService.RESULT_FORMAT_OBJECT. The result contains data similar to this:
<!-- ... -->
<children>
<item><!-- ... --></item>
[Code]....
I get an array named item beneath the element children when there is more than one item sibling. If there's only one, the conversion can't distinguish it from a scalar.
What do I need to change to have Flex convert all item elements to an array with 0 or more elements?
What would I have to do to get an array member children, dropping the item wrappers altogether?
The XML is generated by Struts on the server side. I always have the option to change the structure of the document there, but right now I'm interested in what I can do with Flex.
View 2 Replies
Mar 24, 2012
I hope I am clear enough. My data set is populated I have
comment:CommentVO;
comment.replies=[comment:CommentVO,comment:CommentVO,comment:CommentVO];
_comments:Array = [comment:CommentVO,comment:CommentVO,comment:CommentVO]
I've correctly populated my _comments Array and the replies array in my CommentVO Obj.
[Code]...
View 3 Replies
May 5, 2010
I m trying to make 2, 3 group of animation using multiple arrays, A group having 10 circles and those circles r moving from X to Y (using mainFunction). while moving... i m calling subFunction for blink effect (here my problem comes). So each circle are having two different animation (moving, blinking) ,
also going to make 2, 3 group by calling "mainFunction" Experts pls help me to resolve this problem, or sugges me some other way to make this animation
[Code]...
View 0 Replies
Dec 3, 2005
I have tried creating 4 variables with arrays with random values where there are no two variables with the same value at the same place in the array. For example, if the 27:th value in one variable is 3, then none of the other variables must have 3 as the 27:th value.I thought the part marked blue would do it (I have also tried it with the "while" exchanged for an "if").
Code:
var totalQuestions = 50;
var correctAnswers = new Array();
var wrongAnswers1 = new Array();[code]...
View 4 Replies
Feb 1, 2004
I just had a quick question, anyone know if it's possible to have arrays indexing a series of functions say something a bit like this as an example? AS]genelist[0] = Math.random()*10;[/AS] I am currently trying to get some geneticsstuff i did in director to flash so it can be used in a game, gonna suck if i to have a LOAD of variables with different names
View 5 Replies
Jul 7, 2009
I'm trying to figure out how to generate an array whose elements are each arrays to make a quick loading database of sorts.the main array could essentially be something like "employees" while each employee would have demographic data like age, salary, gender, etc.In some cases the information on some employees would be greater than others, and options created by "push" would imply the number of elements within each employee array would be variable until generated.[code]But I get the feeling this type of array as it is currently described doesn't lend itself well to adding new elements in the way I've described.My goal is once an employee's information has been entered and saved, I can call up their info by array number like aEmployee[2], and if employee 2's name is Bob, then Bob's name would appear in the text field, along with all the other fields related to Bob's array, such as being male, 42 years old, and living in Witchita Kansas.Would I modify a multidimensional array, or do I want an array within an array, and is there a way to add "arrays" as elements?
View 8 Replies
Jan 21, 2011
I am running into some trouble adding an array into another array to create a multi-dimensional array.The code appears as below:
var slideDataArray:Array = new Array();
var slideShowDataArray:Array = new Array();
slideDataArray[0] = xmlData.SlideShowParameters.SlideShowImagesDirectory;[code]........
I am looking for a means of placing the slideDataArray into a 'slot' or value of slideShowDataArray so that I can in the end pass the slideShowDataArray as a parameter to another function.As of now, the last slideDataArray appears 11 times (the loop runs 11 times) in slideShowDataArray and the way the code is written the slideDataArray is unique every iteration of the loop.
View 1 Replies
Aug 26, 2009
I've got a bit that loads a big chunk of xml data about products.I push product info into an array(e.g. productArray), then add that array to another array (e.g. allProductsArray)How do I sort those arrays? For instance, if I want to sort the allProductsArray based on the info in productArray[0]?Alternatively, would something other tha an array of arrays be a better route?This loader loads the same sort of info for many different clients, so the bit to sort on will change.
View 5 Replies
Sep 26, 2011
I'm trying to write a function where I can specify any amount of array, and the return value will be an array containing the contents of all of the specified arrays.I've done this, but it seems like a really slow and ugly way of doing it:
var ar1:Array = [1,2,3,4,5,6,7,8,9];
var ar2:Array = ['a','b','c','d','e','f','g','h'];
function merge(...multi):Array[code].....
Is there an inbuilt and more efficient / nice way of achieving this? The result does not need to be in the same order as the input - completely unsorted is fine.
View 3 Replies
Feb 17, 2009
A little explanation: Im making a random arranging number Array. So instead of using a loop and assigning 0 to first array element, 1 to second, etc.I need to make it totally random but without repeating any numbers. To do that I made a second Array that will have the same number of children to serve as a reference.Each of them will be an Object with a property "num" , wich will be its actual number, and a property "called" wich defaults to false.Like this:
ActionScript Code:
for(var i:int=0;i<vQuantity;i++){
ranArray.push( new Object() );
[code].......
View 8 Replies
Dec 27, 2009
I've had a problem for awhile that was really odd. After some intense debugging, I realized the problem lied in setting an array equal to another array.[code] When setting one array equal to another, the values aren't copied over, but a reference to that memory is stored. So no matter which variable you change, they are both references to the same memory and thus both will reflect the changes.With other data types, this doesn't happen.I could fix it by looping through t1 and using push() to add each index from t1 into t2, but that seems a little messy.
View 7 Replies
Nov 13, 2009
I've been working in a new proyect and i came to this problem that is really getting me tired. I'm supposed to make a given number of items (constructed from an extended Sprite)[code]...
View 1 Replies
Jul 15, 2011
What i have on the stage are lots of balls each with there on name b1,b2,b3 etc. and i have something that is going to hit it with hitTest.
Insted of hardcoding all the balls into the hitTest i want to have a variable containing the first part of the objects name (_root.b) then add i on the the end and i would loop from 1 to how many balls are on the stage eg. 10.
so for my code at the moment I don't have a loop but using "i = 0"
Here is my code:
ActionScript Code:
onClipEvent (enterFrame) {
i = 1;
j = "_root.b"+i+".ball2";
[Code]......
When i trace "mcName" it shows "_root.b1.ball2" which is the correct object, but the hitTest doesn't seem to see it and fails.
If i put mcName as "_root.b1.ball2" (hardcoding it) it works.
Ive tried so many different tweaks and just can't seem to get it to do it.
View 1 Replies
Aug 6, 2009
I'm new to flash, have some experience with HTML and JavaScript.I wonder if and how I can have a flash object in an HTML page that returns or updates a variable in the page, or assigning it to an input element's text property...for example a flash with a form that upon submission updates the equivalent form in the HTML.(I know I can do it all in HTML, just wondered on how its done...)
View 3 Replies