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


Similar Posts:


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 :: Variables Inside Names Again?

Dec 9, 2010

If I have a MovieClip called parent_mc and inside it I have another called child1_mc, I can use a variable for the "1" part of child1_mc and change the alpha for example like this:

ActionScript Code:
var myVar:Number = 1;
parent_mc['child'+myVar+'_mc'].alpha = 0.5;

What is the right syntax to use if child1_mc is not actually a child of anything and just sits on the stage? I have tried the following and it didn't work:

ActionScript Code:
['child'+myVar+'_mc'].alpha = 0.5;

and I tried:

ActionScript Code:
stage['child'+myVar+'_mc'].alpha = 0.5;

That didn't work either.

View 9 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 Variables Inside Loop?

Feb 3, 2011

want to make this stuff working.

Actionscript Code:
for (var i:Number=1; i<=3;i++){ var char_name+i = event.target.data.char_name_ + i;//It should be like//var char_name1 = event.target.data.char_name_1;//var char_name2 =

[code]....

View 2 Replies

ActionScript 2.0 :: Passing Variables Inside A For Loop?

Jan 21, 2009

I'm using a few for() loops to populate my game. Now, I have 2 versions of each function, one that executes when my variable "debug" exists, and the other that activates only if "debug" does not exist.Looks kinda like this:

ActionScript Code:
// first, if debug exists, the script will execute for the single instance of my movie clip "myBox_0".
if(debug){
// assign a value to the string "myTarget"

[code]....

Now, on the line I starred*, if I enter "images/0" instead of what you read there, then it works. But when I try to use the variable "i" then it gives me the error "Error opening URL 'images/undefined.png'" I ran a trace statement to track "i" through the code and it works up until I enter the tellTarget statement... how can I get my script to pass that variable through that statement?

View 2 Replies

ActionScript 3.0 :: Create Variables Inside A For-loop

May 28, 2009

i am trying to "dynamically" create variable names inside a for loop and add them to an array...

[Code]...

// ' this["thumb" + i] ' is definitely not the way to write it.. so how should i write it?

View 1 Replies

ActionScript 3.0 :: Runtime - Get The Variables From Inside The "for Loop"?

Jan 2, 2011

How am i to get the variables zombData.zomb0, & zombData.zomb1 from inside the "for loop" I want this trace command dynamic

[Code]...

View 2 Replies

ActionScript 3.0 :: Getting Variables By Their Names?

May 20, 2010

The thing is, I create a grid on the screen, and each of its element is given a name. The question is, how can I access those specific grid's fields by their names? Here's the code:

ActionScript Code:
private function drawGrid():void
{
var startX:uint = 0;

[Code]....

Now, If I wanted to remove, for instance, the box of the 13th row and the 25th column, how can I do that?

View 7 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.0 :: Array Of Variables - Make A Bunch Of Variables From A For Loop

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

ActionScript 3.0 :: Accessing Loop Variables Outwith Loop

May 5, 2011

Say, I had a loop in a function...

[Code]....

How would I refer to a in another function

View 8 Replies

Javascript :: Get The Names Of Variables From A Web-page?

Aug 15, 2011

Is there a way to get the names of variables from a flash game? I have been playing with my players health with the code;

javascript:document.embeds[0].SetVariable("_root.player.intHP", 0)

I am looking for a way to find out the rest of the variables, like damage and such.

View 1 Replies

ActionScript 2.0 :: Putting Variables Instead Of Names

Jul 26, 2004

if i have mc duplicated or an object instance name thats stored inside a variable how can i call it? for ex: _root.mov1._x = 53; What if i want instead of mov1 a variable name. lets say randomname is a var and it holds the name of a duplicated object with a name i dont know since its random. now how can i call it just like the example above cause i tried
_root.varname._x=33; but it thought varname was an instance name instead of var.

View 5 Replies

ActionScript 2.0 :: Get Instance Names For Variables

Jul 13, 2007

There's a way to get the instance name of objects/symbols for variables and use this in actions and/or functions?

View 4 Replies

ActionScript 2.0 :: Using Variables As Instance Names

Nov 11, 2010

So, I have something like..

Code:
select = ("block" + number);
trace(select._currentframe);
number++;

This is because I have 5 movieclips named block1, block2, etc. However, it returns undefined. When I directly state the instance name, like:

Code:
trace(block1._currentframe);

It works. How do I use variables as instance names?

View 2 Replies

ActionScript 2.0 :: Putting Variables Instead Of Names?

Jul 26, 2004

if i have mc duplicated or an object instance name thats stored inside a variable how can i call it?for ex:

_root.mov1._x = 53;

What if i want instead of mov1 a variable name. lets say randomname is a var and it holds the name of a duplicated object with a name i dont know since its random.

now how can i call it just like the example above cause i tried

_root.varname._x=33;

but it thought varname was an instance name instead of var.

View 5 Replies

ActionScript 2.0 :: Adding Properties And Events To MovieClips Inside A Loop Inside A Function

Dec 8, 2009

I have done this same thing in ActionScript 3, but am not familiar with ActionScript 2, which I am forced to use for this project. I am loading products into a SWF via XML and attempting to add a click event to each dynamically-created movieclip. Simply tracing the text from a node in XML will do for now. I'd like to assign a property called "desc" or "description" to each movieclip and have it trace that property's value when clicked. Here is the relevant portion of my code as it stands:

ActionScript Code:
var iXML:XML = new XML();
iXML.ignoreWhite = true;

[Code].....

View 6 Replies

AS3 :: Image - Add A Child Inside A Newly Created Instance, Inside Of A Loop?

Feb 2, 2005

I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.

var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();

[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 :: 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 :: 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 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

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

AS3 :: Add A Child Inside A Newly Created Instance, Inside Of A Loop?

Jun 6, 2010

I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.

var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();

[Code]....

It dies every time on that last line. How do I refer to that vidThumbn instance so I can add the imageLoader? I don't know what I'm missing. It feels like it should work.

View 2 Replies







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