ActionScript 3.0 :: Using For Loop To Set Function Names From Array

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


Similar Posts:


ActionScript 2.0 :: Array Instance Names - Call In A For Loop?

Jan 3, 2006

I have 35 textboxes with the names "t1" to "t35". How would I call these names in a for loop? I have tried this with no luck:

[Code]...

I know I'm doing something wrong with the ("t"+i) but I dont know how how to combine a string and number like that.

View 7 Replies

AS2 :: Professional - Loop To Include All Movie Clips In The Array Without Having To Type Out All Their Names?

Sep 1, 2010

I have a simple array of movie clips ("box1" "box6") that I have created on the stage. I then have a simple onRollOver function that is iterated for each of these movie clips, as shown below. As it is now it's working fine, but I can forsee two potential problems for when I use larger arrays and apply this technique to my real working files.

If I were to have many more movie clips, the first line of code would be much longer as it lists each movie clip instance name. Is there a way to use, for example, a for loop to include all these movie clips in the array without having to type out all their names? As you can see here, I have used a simple numerically-incremented naming process. I think the problem may be that I am using movie clips with instance names assigned on the stage and not created through ActionScript.The function as I have created it makes all the movie clips gotoAndStop(1) and then the one that has been rolled over goes to frame 2. Is there a way of making all the movie clips in the array except the one that has been rolled over gotoAndStop(1), ie. is it possible to exclude the rolled-over movie clip from the first part of the function? Here it works just fine as it is, but I'm thinking that maybe when I start using more complex functions with tweens etc it may cause problems. Or not?

[Code]...

View 5 Replies

ActionScript 3.0 :: Using An Array To Store Function Names For Use Later?

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

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

Assigning Tween Function In An Array Through A Loop?

Mar 17, 2010

I have been trying to assign tween function in an array through a loop in as3.I have 20 mc on stage, the instance names are obj1, obj2 and so on.I want to assign a tween function to each of them, the function looks like this :

Actionscript Code:
function startTween(e:TweenEvent = null):void {xTween = new Tween(obj1, "x", None.easeNone, obj1.x, Math.random()*20, 0.2, true); 

[code].....

View 3 Replies

Flash - Using Array And Loop / Push Function

Apr 2, 2011

what I'm trying to do is to get 4 movieclipps (leaf1, leaf2, leaf3, leaf4) to play the sound that is attached to them when is dragged onto another movieclip (NatureTarget) and the play button is pressed so that the sounds are played in the order they are dragged on. I know I need to use an array and the push function and a loop...

View 1 Replies

Actionscript 3 :: Which Is Faster, A For Loop Or The ForEach() Array Function

Oct 4, 2011

I'm wondering which is faster in AS3:

array.forEach( function(v:Object, ...args):void
{ ... } );

Or

var l:int = array.length;
for ( var i:int = 0; i < l; i++ ) { ... }

View 3 Replies

ActionScript 2.0 :: Loop Through An Array Of Mc's, And Assign Each A OnRelease Function?

May 19, 2009

I want to loop through an array of mc's, and assign each a onRelease function. I have the following code but the trace inside the function doesn't seem to find the array.I understand why but what is the correct way of doing this?

ActionScript Code:
var theArray:Array = new Array();
var j:Array = new Array();[code].......

View 1 Replies

ActionScript 2.0 :: Place A For Loop In A Recursive Function With The Function Call Within The Loop

Nov 4, 2005

If you place a for loop in a recursive function with the function call within the loop... will the loop finnish or does it stop working untill the last recursion?

View 2 Replies

ActionScript 3.0 :: Create Dynamic Array Element Names Based On Another Array?

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

ActionScript 3.0 :: Error When Using Array And Loop #1006 : "value Is Not A Function"?

Apr 20, 2009

I have a set of 15 buttons on my stage. Trying to use an array with loop to quickly populate a new array with the instance names of my buttons, then add eventlisteners to all of them quickly too. And yes, I do have the Handler functions written out too, but I didn't include, because the error I'm getting is "TypeError: Error #1006: value is not a function"

and the error keeps pointing to each of of the eventListeners within my for loop.Its saying that each of those eventListeners is a value that is not a function. ?

var btnList:Array = new Array();
var numBtns:int = 15;
for (var i:Number = 0; i < numBtns; i++)[code]......

View 6 Replies

ActionScript 2.0 :: Property Names In Loop?

Jun 8, 2011

i was searching for the solution all over the internet but could not find the way to solve this problem . I have a loop in which i want to assign one property value ( in this case value of several numeric stepper components) to one array spot. Unfortunetaly i cant figure out how to change the property name acording to number of the loop. Here is an example.

Code:
hours0.value = 5;
hours1.value = 6;

[code].....

View 4 Replies

ActionScript 2.0 :: Object Names In For Loop?

Jan 6, 2003

I have 8 text boxes (called h1, h2 etc) that I want to do things with, the code below is just to make them all invisible when the movie loads,this works:

for (b=1; b<9; b++) {
_root["h"+b]._visible = false;
}

[code]....

View 1 Replies

ActionScript 2.0 :: [F8] Assign Names In A Loop

Apr 13, 2009

I'm trying to imitate the spining preloader that fades as it rotates and I can't remember how to name each of the lines that are created with this code so I can later add the script to modifiy their independent alpha as it turns.

I don't know wether I need to create another function or what to do...

var numLines:Number = 12;
var extRadAsterisc:Number = 20;
var intRadAsterisc:Number = 10;
var centreX:Number = 110;

[Code].....

View 2 Replies

Actionscript 3 :: Loop Through All Params Without Knowing Their Names?

Nov 30, 2011

I have a few functions that accept several parameters. [code]...

Is there a way to loop through all the params (without knowing how many or their names) and put them in some kind of an array with their names, so I'd get an associative array [code]...

View 2 Replies

ActionScript 3.0 :: Variables' Names Inside A Loop?

Jul 19, 2009

i want to query about a point here,

Now, When i make a loop for example a "for" loop

ActionScript Code:
var i:int;
for (i=0;i<4;i++){
// Looping Code For 4 Times
}

in the looping code, when i use a variable, for example "myVar"

Can i make the variable name be "myVar0" in the first time looping, and the name be "myVar1" in the second time looping, and so on ..

View 6 Replies

ActionScript 3.0 :: Loop Through Children And Add Them Instance Names?

Jan 14, 2010

how could I make a simple loop which loops through the childrens of specific movie clip and add each of them instance name lets say "iname", since I have movie clip in which childrens are not added by code.

And if I'm sure I could acces those childrens then by code like iname.x = 100?

View 6 Replies

ActionScript 3.0 :: Making New Variables With New Names In A For Loop?

Jan 24, 2010

I can't create new variables within a for loop:

ActionScript Code:
for(var i:int = 0; i<numBtn; i++) {
var this['menuBtn'+i] = new Sprite();
}

This doesn't work, saying I need an identifier before 'this'.

What I am trying to do is to make a dynamic menu, and the number of buttons depend on how many files there are in a directory, as each button links to each file;I get this value (numBtn in my example) from a php script, and I need to make a menu depending on it, but I can't seem to make it so that when I add a new file into that directory, a new button comes up on the menu and I don't have to change my flash file.

View 9 Replies

Actionscript 2.0 :: For Loop That Dynamically Names Variables?

Dec 19, 2008

Still learning how to use for loops, I want to set a huge range of Boolean Variable to false. like:

var met0:Boolean = false;
var met1:Boolean = false;
var met2:Boolean = false;
etc... etc...

how can I dynamically name variables inside a for loop and set its data type? I know how to with movieclips but can't get it to work with variables

View 4 Replies

Actionscript 3.0 :: For Loop Iterating Instance Names?

May 10, 2010

I have a few MCs named fruit1, fruit2, fruit3, all instanced off a MC...I would like to loop to shorten my code and just loop through and stop all of them at once... My Code:

for (var i:Number=1; i<=7;i++){
fruit[i].stop();
}

I get an 1120: Access of undefined property fruit.I want the result of my loop to do:

fruit1.stop();
fruit2.stop();
etc..

View 4 Replies

ActionScript 2.0 :: Create Several Tweens With Different Names In A For-loop?

Jan 7, 2010

How can I create several tweens with different names in a for-loop?

I want to create one tween named tween0, one tween named tween1 etc. up to tween9.

Like this: (This doesn't work)

Code:
for(i=0; i<10; i++) {
var ["tween" + i]:Tween = new Tween(...);
}

View 2 Replies

ActionScript 3.0 :: Loop Through Childrens And Add Them Instance Names?

Jan 14, 2010

how could I make a simple loop which loops through the childrens of specific movie clip and add each of them instance name lets say "iname", since I have movie clip in which childrens are not added by code.

P.S.: And if I'm sure I could acces those childrens then by code like iname.x = 100?

View 2 Replies

ActionScript 3.0 :: Loop Through A List Of Similar Names?

Mar 29, 2012

I have this:

Code:
function onAdd(e:Event){
switch (getQualifiedClassName(e.target))

[code].....

View 5 Replies

ActionScript 3.0 :: Assigning Names To Movie Clips In Loop?

Mar 21, 2009

im trying to run a loop and assign all my new movie clipswith different names. i have tried .name and ._name they dont seemto be working..

for (var i = 1; i<=5; i++) {
imageName = new ImageMovie();
this.addChild(imageName);

[code].....

View 1 Replies

ActionScript 3.0 :: Dynamic/unique Variable Names In A For Loop?

Jun 24, 2009

am trying to load xml and make button for its length, and try to make function for each button i have i make buttons and i give them a unique name , but i can't make function for every one?here is the code
 
/////////////////////////////
var xmlLoader:URLLoader = new URLLoader();var my_Arr:Array= new Array();var arr_posX:Array =new Array();//= ["350","350","350","350"]var arr_posY:Array=new Array();//= ["80","120","160","200"]xmlLoader.addEventListener(Event.COMPLETE, showXML);xmlLoader.load(new URLRequest("Models.xml"));function showXML(e:Event):void {    XML.ignoreWhitespace = true;    var songs:XML = new XML(e.target.data); 

[code]....

View 3 Replies

ActionScript 3.0 :: Refer To Instance Names Inside A For Loop?

Jun 3, 2010

I have several movie clips labeled thumb0, thumb1, thumb2, etc.
 
How do I refer to these instance names inside a for loop? I want to do something like:
 
//DISPLAY THE THUMBNAILSfor(var thumbCount:int = 0; thumbCount < loadedThumbs.length; thumbCount++) {     ["thumb" + thumbCount].visible = true;
}

View 8 Replies

ActionScript 3.0 :: Dynamic/unique Variable Names In A For Loop

Oct 4, 2011

im trying to load xml and make button for its length, and try to make function for each button i have i make buttons and i give them a unique name , but i can't make function for every one ?

/////////////////////////////
var xmlLoader:URLLoader = new URLLoader();var my_Arr:Array= new Array();var arr_posX:Array =new Array();//= ["350","350","350","350"]var arr_posY:Array=new Array();//= ["80","120","160","200"]xmlLoader.addEventListener(Event.COMPLETE, showXML);xmlLoader.load(new URLRequest("Models.xml"));function showXML(e:Event):void {    XML.ignoreWhitespace = true;    var songs:XML = new XML(e.target.data);   

[code]....

View 2 Replies

ActionScript 2.0 :: Movie Clip Names For Each Loop - Turn The S[z] Into Something Like S1 - S2 Or S3 ?

Jul 6, 2003

okay here's my code

Code:
onClipEvent (enterFrame) {
for (z; z<4; z++) {[code]....

how do you turn the s[z] into something like s1 - s2 or s3 ? i just want different movie clip names for each loop..

View 2 Replies

ActionScript 3.0 :: Dynamically Referencing Objects Names In Loop

Jul 12, 2009

The problem is referencing object names dynamically in AS3, in a loop. Example. I have an array called c4 which i would like to reference like this:

I have a number
var x:Number = 4

How can I do something like
trace(["c"+x].length);
(I know this is wrong!)

Same with other objects
E.g. Movieclip called mc4
["mc"+x].x = 100;

View 3 Replies







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