ActionScript 3.0 :: Name Arrays With Variables (strings And Integers)?

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


Similar Posts:


ActionScript 3.0 :: How To Put Strings / Functions Into Arrays

Dec 6, 2010

When I experimented with it, I tried to push one string and one function named "moveRight" into the array,
Code:
_behaviours.push("1", moveRight);
trace("_behaviours: " +_behaviours);

But when I trace the content of the array, I get
Code:
_behaviours: 1,function Function() {}

Why is my function moveRight, being renamed to "Function", and how do I call the different functions if I have several of them in one array? The purpose of all this is to make a simple AI system for my game enemies. After the enemies are added to stage, a special function would calculate a random number based on the number of entries in the array and then make the enemy perform the chosen function.

View 3 Replies

ActionScript 2.0 :: Getting Percentage Similarities Between Arrays/strings?

Oct 23, 2009

long time admirer of the wisdom on this board! I am having a little trouble thinking of a solution to this little problem.So in AS2 (will make the jump to as3 soon, i promise )I have some code that makes arrays of the formn, e, se, e, n they are only 5 elements long at mostI load in some XML with similar arrays, i would love to know if you guys have any suggestions on how i can work out the percentage difference between these arrays.It will be for a gesture recognition type app, but in essence i suppose this section of the code is a spell checker that gives a suggestion for the best match from a custom dictionary.

View 1 Replies

ActionScript 2.0 :: Flash8 Strings, Arrays, And Splitting Errors

Jul 18, 2009

the general goal I'm going for is this: user enters a bunch of text into a textarea. It's parsed word by word into an array, and then the array is gone through. If a certain word (from a list provided by me) is found in the array, then an event will happen later..

[Code]...

View 5 Replies

ActionScript 2.0 :: Arrays/Objects/Strings - Attach A MC Instead Of Text In A Textfield?

Oct 25, 2003

how can i have an array of strings but also with mc identifiers in the same array and have it know the difference between object and string? RIght now i've got this array of strings that goes to a textfield, and if i change it to

portfolioSection(["section 01", "section 02", {linkage: "linkage_id", x: 530, y: 280}, "section 04", "section 05"]);

this.attachMovie(portfolioSection[2].linkage)[/AS]

to try and attach an MC instead of text in a textfield i just get [object object] in the text field.

View 6 Replies

Flex :: Combining A Multiple Strings And Arrays To One DataProvider For Spark List

Dec 21, 2010

what I need to do is combine 5 arrays with 5 individual strings (which have come from a JSON webservice) into one single list item in FlashBuilder Burrito. [code]I've pulled these out successfully and each one traces in the debugger, although as I need them all in the same list I'm struggling to establish them as a dataprovider together.If I push the strings and arrays together it is impossible to read properly, as the main Titles are at a different level to any descriptors for the products which are in the arrays.

View 1 Replies

ActionScript 2.0 :: Pushing Variables To Arrays Within Arrays?

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

Actionscript 2.0 :: Combine Strings +variables To Be Read As An Object?

Feb 3, 2010

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 ?

View 4 Replies

ActionScript 2.0 :: Building GetURL Query Strings With Variables

Nov 23, 2004

I have a querystring passing a var to my .swf. This var is getting into the movie fine and I can output it in a text box, but I'm having problems "rebuilding it" into my new getUrl. Here's what I have:
Code:
on (release) {
getURL("index.cfm?searchtype=" & _root.searchtype & "");
}

What I'm looking to see interpreted by the browser is:
Code:
on (release) {
getURL("index.cfm?searchtype=OH");
}
(where the value of _root.searchtype is "OH"). [URL]

View 2 Replies

ActionScript 3.0 :: Retrieving Variables From Text File / Converting Strings To Dates

Nov 9, 2008

I'm trying to read date variables from an external text file. I'm using the LoadVars method and it is working fine for regular string variables. I'm running into trouble trying to convert some of those strings into date variables so I can compare the current date to the targetDateX variable from the text file. I'm working on a countdown timer for a list of different times/dates. It will display the time left until the first event, then after that event the time left until the second event. I'm running the code in a for loop and everything is working except being able to convert the string with format (yyyy,mm,dd,hh,mm) into a date variable- I've attached a sample of where I'm having trouble.

View 1 Replies

ActionScript 3.0 :: Push Multiple Strings Into An Array, And Some Of The Strings Are The Same?

Aug 24, 2009

I work on AS3 one week, and then take a break for a few weeks, then work on it a day, take a break, etc.. So I forget some of the basics, and need refreshers. I think I need to stop taking breaks.

Problem: I push multiple strings into an array, and some of the strings are the same.

Code:
var myArray = new Array();
myArray.push (Snivvle);
myArray.push (Kirupa);
myArray.push (Snivvle);

I want to find out which element positions "Snivvle" hogs up. We can see that it would be using element 0 and 2, and if we do an "indexOf" we would only get to see element 0, and doing a "lastIndexOf" we would only see element 2. How do I find out ALL of the element positions "Snivvle" is located in, so that it returns: element 0, element 2.

View 2 Replies

ActionScript 2.0 :: Problems With Arrays And Variables

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

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

ActionScript 3.0 :: Convert String Of "get Variables" Into An Object Of Strings?

Jun 15, 2010

I'd like to easily convert a string of say "dog=Sam&cat=Garfield&mouse=Cheese" into an object of strings.

The object would contain the variable "dog" equal to "Sam", its variable "cat" will be "Garfield", and of course "mouse" the string "Cheese".

There are a number of ways to parse this, but what is the simplest way? I know when you use a URLLoader object, you can give it a dataFormat of URLLoaderDataFormat.VARIABLES and then it automatically converts the data into an object.

View 7 Replies

ActionScript 1/2 :: Object Variables (arrays), Persisting To A New Keyframe?

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

Copying Arrays - Instance Variables - Multiple Animations?

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

Professional :: Separate The String And Push The Different Variables Into Their Appropriate Arrays?

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

Arrays :: Saving X And Y Cords As Variables On Mouse Click?

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

ActionScript 3.0 :: Loading Info Variables And Arrays From A Webpage?

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

ActionScript 3.0 :: Way Of Reducing Amount Of Code / Using Variables And / Or Arrays

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

ActionScript 2.0 :: Redeclaration Of Variables - Wipe An Arrays Content?

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

ActionScript 2.0 :: Associative Arrays - Store Variables And Change Values

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

Actionscript 3.0:: Flash - How To Display Integers

Mar 30, 2011

im new to flash - actionscript 3.0. I have created a text and i am able to set a string by doing txt.text = "something". My problem is, i want to display an integer instead of a string, how is this possible?

View 3 Replies

Actionscript :: Integers Numbers In The Debugger?

May 9, 2011

I've stumbled upon a strange thing in Flex. I created an integer variable:

var foo:int = 1;

And in the debugger it says foo is a Number with a value of 1.It wasn't a biggie for me but seems Numbers are being sent instead of integers when doing remote service calls. What's happening here?

View 2 Replies

ActionScript 2.0 :: Loadvars To Load Integers?

Sep 18, 2009

I've been busting my head forever on this... I'm trying to load variables from an external txt file in the same folder as my SWF file to be used as normal variables in _root and not in Text Fields, every method or Tutorial I found and tried with both LoadVars() and LoadVariables() only works with loading into Dynamic Text Feilds but there is no way I can copy those values into normal variables to be used for other purposes like integers and normal strings...

I've read over a dozen tutorials and tried more than 30 different lines of code but there seems to be no way to get the values into normal variables, the list of things I've tried is way too long to mention, so I'll just ask, anyone here know how to load values into normal variables and perhaps an Array? my text file is called "Strings.txt" but again I do not want to load those strings directly to a text Field I want them to be used in a different area...

View 0 Replies

ActionScript 3.0 :: Adding Numbers To Integers?

Jan 30, 2011

Code:
var result:Number = int(driven.text) / int(mpg.text);
result1.text = String(result);
var result:Number = int(driven.text) / int(mpg.text + 3);

[Code].....

for some reason it doesnt work properly...the correct equation should work like this:

12000 (milesdriven) / 20(mpg) = 600
12000 (milesdriven) / 23(mpg + 3) = 521
600 - 521 = 79(gal.)
79 x $2.75 = $217.25

what im having problems with and what i need to function is that the MPG input has a +3 to any number inputted (i.e. 20 becomes 23)

View 3 Replies

ActionScript 2.0 :: Loading Integers From XML File

Aug 6, 2005

I'm loading an XML file into flash, one of the fields is an ID of them item in the database the XML file was made from.I can load everything fine and have put all the data into a multi-dimensional array, but for some reason the ID is a string. I've tried using Number(myID), to covert it to an integer but nothing seems to work.So how can I load an Integer into Flash using XML and have Flash recognise it as an Integer?

View 1 Replies

ActionScript 3.0 :: Error #1009 When Subtracting Two Integers

Sep 11, 2010

I'm getting Error #1009 when subtracting two integers inside a class function.This code throws Error #1009:

ActionScript Code:
var difference:int = getTimer() - this.starttime;
if (difference >= 1) {

[code]....

starttime and countdown are declared as:

ActionScript Code:
public var countdown:int;
public var starttime:int;

and initialized in the class constructor by:

ActionScript Code:
countdown = Math.random()*60 + 90;
starttime = getTimer();

View 5 Replies

ActionScript 3.0 :: Integers As Dynamic Object() Properties?

Jul 28, 2011

I heard that dynamic Object() properties, when looped through via a "for in" do not preserve their original order they were added to the Object.However if I use integers as object properties like this:

ActionScript Code:
import flash.utils.Dictionary;
var obj:Object = new Object();

[code]......

View 2 Replies

Actionscript :: Use Two Integers To Represent Integral Part Of Double?

Sep 7, 2011

I'm getting a millisec timestamp in ActionScript as a Number object which can return a primitive double. I'd like to cast it for a backend that expects a primitive long long millisec, however the language does not provide long long. Am thinking a double can be converted to two ints and submitted together. Any encounter something like this and have a solution?

View 1 Replies







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