ActionScript 3.0 :: Creating Array With Dynamic Names From Within Function?
Oct 15, 2009
I've got an array (slides) that I parsed from an amfphp return that contains the following data in each array element:
slides = (chapterName, lessonName, slideName, slideText), for every slide in the course
I'm trying to get arrays out this that will look like:
chp1Array = list of Lesson names in that Chapter
chp1Less1Array = list of slide names in that Lesson
chp1Less2Array
chp2Array
chp2Less1Array
chp2Less2Array
chp2Less3Array
etc. etc.
This wouldn't be a problem in as2 but I can't get it to work in AS3 because it gives me errors when I try to create the arrays with dynamic names from within the function? How to get the dynamic number into the array name...
View 9 Replies
Similar Posts:
Jun 13, 2009
I have a function that is called from a timer event. Every time the event is called I need to create a new Array with a unique name:
Code:
var dropNumber:int = dropHead.length - 1;
var ["dropTail" + dropNumber???]:Array = new Array();
I am not sure how to dynamically change the name of an array with as3. Also, just a bonus question, is it more efficient to have a single array broken into partitioned indexes or have several arrays of data?
View 3 Replies
Jun 22, 2010
Is there a way to make dynamic var names? Cant remember how to do this.
Something like:
NameCount = 1;
Obj.eval("Item" + NameCount)) = "hello world";
Obj.Item1 // trace "hello world"
View 3 Replies
Jun 28, 2009
Is it possible to, if you have an array of class names like ActionScript Code: var city01names:Array = ["pic_01", "pic_02", "pic_03" ...] make a new array which would read these names, instantiate them, and push them into a new array containing the instances of all these pictures, which I could then use for a slideshow?
[Code]...
View 7 Replies
Apr 6, 2009
the error I recieve i:Instantiation attempted on a non-constructor.
Relevent Code:
private var hoverText:MovieClip;
private function createTexts():void{ for (var i:Number=0;
[code].....
View 4 Replies
Oct 29, 2009
I create X instances of a class (called SM) depending on a varibale I have (called here howmany), but later on as I want to check their states with a while, I need to have diferent instances names (sm1,sm2,sm3...).[code]
View 1 Replies
Dec 14, 2010
I was wondering if it was possible to create the name of a NEW array dynamically. I have tried the following with no success. Does anyone know if this can be done?
Actionscript Code://Tried and failed_global["newArray"+newArrayNumber] = new Array();//Tried and failed_this["newArray"+newArrayNumber] = new Array();//Tried and failednewVariable = _this["newArray"+newArrayNumber];newVariable = new Array();
View 1 Replies
May 28, 2009
This should be simple but I can't come up with or find the answer anywhere. All I want to do is create a series of Arrays with instance names generated on the fly. I then want to reference these later. I have a "for" loop with a variable "count" that I want to add to a base name of rowArray and use the result to create an Array. I would think that it would look something like this:
[Code]...
View 2 Replies
Nov 27, 2007
I am making an XML multiple-gallery flash site for a client. The chunk of code I am having trouble with is populating the thumbmails section of the site with all the pictures in all the galleries. The image paths are brought in and stored in an array - one array for each gallery's image paths. The problem is that when I try to cycle through all the images to put them into movie clips (using a fore statement) I am having trouble dynamically addressing the arrays. More specifically, flash interprets them as strings, and does not evaluate the variables in them.
Code:
function images(i){
var temp:Number = eval("g"+i+"im.length");
for (var r:Number=1; r<=temp; r++){
[Code]....
The argument images() takes is the gallery number (from another function). I have tried using eval() and trace to see what the problem is. Basically I can make it output the correct STRINGS, but flash will not convert the variables in the strings! So in the URL (first arg) of loadMovie it is seeing something like "g2im[3]" as a string, and not evaluating it to the value at index 4 of that array.
View 2 Replies
Mar 13, 2009
[code]I've tried some various things (including "this"), but basically, I need to loop through data held in arrays to create several dynamically named functions on the the fly.
View 1 Replies
Sep 15, 2011
I am writing my quest .as files for my RPG that I am making. At the present moment I am having issues with certain commands and how best to accomplish them. This pertains to my conversation system that I have in place. Currently, the conversations are stored as an array, with each index in the array representing a different "page" of the conversation. Now for my quests, at the end of each conversation (the last index in the array), I want a certain function to occur (receiving the quest, updating the quest, completing the quest). So my thought is to have a separate array with the same number of elements as the conversation array, and when the conversation text is updated to reflect the next page, it also will access the function array with that given index, and therefore only on the last page of the conversation will the function be executed.
Code:
var a:Array = [func0, func1, func2];
function func0():void{
trace(0);[code].....
Now my question is this, when is the code actually executed? When it is placed within the array, or when it is accessed with the for statement?
View 3 Replies
May 27, 2010
I'm trying to create dynamic function names, something like this:
[Code]....
View 1 Replies
Dec 14, 2011
Is there any way that you can have dynamic variables inside of a static function considering that you can't use "this" inside a dynamic function.
What I am trying to do:
public static function convertToDynamicString(pString:String):String
{
if(pString == "" || pString == null) return "";
[Code]....
View 3 Replies
Jun 19, 2011
openList = Array([1,1], [2,3], [4,5]);
containss = function (input, arrayData, tellID) {
for (i = 0; i < arrayData.length; i++) {
if (arrayData[i] == input) {
[code]....
This code returns false when openList contains 2,3. When I add trace(arrayData[i]), I get 1,1 2,3 4,5 and when I do trace(input) I get 2,3.
View 1 Replies
Sep 29, 2010
I am creating a scrolling portfolio, but am having issues assigning movieclips to an array. I'm loading xml with the image info. That works just fine. I've created an empty movieclip in my library called pane() and set it to export for actionscript with a class name pane.
[Code]....
View 6 Replies
Dec 2, 2010
I've Googled & Binged to no avail. I'm trying to create a dynamic menu in Flash using PHP & MySQL and bring it into Flash using AS3 DataProvider. My menu works fine with a local Array, but I seem to have an issue with the Type being a String and not an Array, but how do I set it up properly so the types are correct? So I started with a typical, non-dynamic array and it works to create my menu:
[flash=]var items1:Array = [
{myClass:"SCI101", question:"What color is the sky?"},
{myClass:"MATH110", question:"What is the square root of 81?"},
{myClass:"SCI101", question:"How fast is the turtle?"},
{myClass:"SCI101", question:"How far is the Earth from Mars?"},
{myClass:"xXxXxXx", question:"xXxXxXx"},
[Code] .....
View 1 Replies
Oct 5, 2011
so I have writing a function that returns objects on the stage and puts them into an array. and the function works fine until i call the function on more than one object name, meaning if im in the root class, and I call this function on object1 lets say it will add all the object one's from the stage, but if i call it on object2 it will throw an error, which makes some sense, i guess it means that it is not adding it to a unique array, but im not sure how to do that. would it be a good idea to maybe make a multidimensional array? if that is the case would it be too slow?
[Code]...
View 1 Replies
Jun 22, 2010
Ok, Background. I have two objects both of which im spawining in though code. We will call them bullets and wolves. They have their own .AS files which tells them everything they need to know about themselves. I figured i would do most of the hit testing on the bullet.AS file, hit testing against the wolves as there were going to be a set number of wolves but not a set number of bullets.o, I named them by running a loop and putting the linenewWolf.name = i.toString();Yes, new wolf is a declared variable, and i is the name of the variable that makes the loop run. I also have a test in it, and it works fine.
However, The hit testing is where i come into an issue. Remember, its on a seperate .AS file. The wolf maker and namer is on the main flash page.The hit testing function isif(this.hitTestObject(a)){i changed up my variable name to run a second loop. first variable name is "i" and the second variable name is "a"And for some reason i get a type error 1034, which from what i understand is an error that you get when two instance names are the same. Also, If possible, i would like to add letters to the name of the object, but im not sure if flash will let me as i belive the code would look something like this
View 1 Replies
May 8, 2009
use a loop to create a set of variable names. The forums have figured out how to do this in AS2. This works in AS2...
PHP Code:
for(var x=0; x<3; x++) { this["var"+x] = x;}trace(var1); // 1trace(var2); // 2
View 4 Replies
Oct 28, 2011
I have a movieclip that I need to duplicate dynamically based on an outside variable.e.g. clip1, clip2, etc This variable changes so I can't hardcode the number of times it occurs.Is there a way to dynamically create this movieclip multiple times and align it according on the screen?
View 3 Replies
Sep 13, 2009
I want to create object instances based on user input but I can't figure out how to get a unique variable name for each instance (I want to be able to get at and manipulate them later). In other languages I would usually just use an eval() function to pull this off.
[Code]....
Code: 1119: Access of possibly undefined property charlie through a reference with static type poundConuter. poundConuter.mxml
View 1 Replies
Dec 22, 2009
I create buttons, but I am trying to give them each instance names so can target them individually but I keep getting undefined property error.
Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var menu_items:Array = ["CHAPTER I","CHAPTER II","CHAPTER III"];
[code]....
View 1 Replies
Aug 16, 2007
I'm currently making a TicTacToe game to help build my Flash experience and I've come across an issue. I'll try and explain what everything is doing in my code thus far. I know it's a lot of code for a forum post, but I don't want to leave anything out as someone may have a really nice way to work with this.
Code:
this will be switched to a user defined value (1 or 2), depending on which person the user decides should go first. currently it is set up for the 2nd player to go first
new _global.whosTurn();
_global.whosTurn = 2;
//this sets all cells DISABLED so, at the beginning of the game, any cell is selectable
cell1_isUsed = false;
cell2_isUsed = false;[code].....
View 4 Replies
May 28, 2011
I am trying to use a for loop, to place 5 instances of the same movieclip on the stage. In the loop I used .name to give each movieclip a unique instance name. But when I try to reference one of those instance names in an event listener I get an error. Here is an example of what I am trying to do:
Quote:
var xPos:int = 120;
var yPos:int = 60;
for (var i:Number = 1; i<=5; i++) {
[Code].....
This code generates an error saying that the cStar2 property is undefined. In the example above, does the for loop create 5 copies of the movieclip starC_moov, and give them unique instance names cStar1, cStar2, cStar3, cStar4 and cStar5?
View 1 Replies
Jul 25, 2010
I am trying to create a list of names which is generated by a swf file that contains buttons representing letters of the alphabet. The user generates a name by clicking on the letter buttons until the letters of the name have been spelled out and then clicking on abutton to add each name to the list. The names are generated inside the swf file but I want the list of names to be deposited in a file within a folder of the computer and remain there as a permanent record after the swf file has been closed. I can do the Actionscript 3 programming associated with the letter buttons but I would like to know how to send the names to the computer file.
View 15 Replies
Sep 25, 2008
I'm trying to create various tween for various movies, comething like this:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;[code].....
My problem is how to call a specific tween to stop it, for example: onrollover stop the tween assigned to "barra3" mc for example. I can't use bot_alpha.stop() it doesn't work. I think it's because i have multiple "bot_alpha" tweens, i need something to dynamic create bot_alpha1; bot_alpha2; ... ...
View 5 Replies
May 1, 2003
i have an array of array names, but i'm having trouble with it being considered a string:
<BR>
onstageArray = ["_root.backstageArray", "_root.perfArray"];
<P>
[code].....
View 2 Replies
Mar 14, 2011
I've been seaching on how to get the key names of a flex Array as there is no such function in the Array class. Here is my answer that may be usueful to any of you.
View 2 Replies
Oct 21, 2010
I have an array called mclipArray with the names of movie clips stored in it as follows:
mclip0, mclip1, mclip2, mclip3....and so on until mclip99.
Later in my code I want to run a loop using "i" as a counter variable from 0 to 99 and then depending on the value of "i" add various movie clips to be inside the movie clip that corresponds to "i". For example if I want to add a movie clip called "someMovieClip" as a child of my movie clip called "mclip6" and my loop has been running and "i" is now equal to 6, how can I use "i" to reference the correct index stored in the array.
mclipArray[i].addChild(someMovieClip);
The above code doesn't work.
View 7 Replies
Nov 22, 2010
I want this to be sorted by first name only: "John Smith 18", "Charlotte Smith 59", "Chris Doe 26", "Tony Jordan 100", "Charlotte Roberts 17", "Imad Hanna 26", "Charlotte Smith 13"
I can get it sort sort alphabetically just by using .sort(), but it takes into account the last name as well.
View 4 Replies