ActionScript 3.0 :: Declaring Variables With A For Loop?

Nov 21, 2010

I want to declare 8 variables at the class level like this:

Code:

private var graphicDesign1:Sprite;
private var graphicDesign2:Sprite;
private var graphicDesign3:Sprite;
private var graphicDesign4:Sprite;

[code]....

But I would like to do it with a for loop. Is that possible? If so i'm doing it wrong this is what I have.

Code:

for(var i = 1; i < 9; i++){
private var +"graphicDesign"+i:Sprite;
}

View 1 Replies


Similar Posts:


ActionScript 2.0 :: Defining Variables - Unique To Load SWFs Instead Of Declaring All The Variables

Mar 21, 2012

I have an empty SWF that's sole purpose is to call loadMovieNum and start the project. Each loaded movie has a few variables defined within them - unique to those loaded SWFs. Instead of declaring all the variables in each SWF can I declare all of them in one place, in the first frame of the empty loader it all starts from? I'm thinking I can then declare a variable which each loaded movie can increment as needed for me.

View 2 Replies

Actionscript 3 :: Declaring Variable In Loop Or Before Loop?

Nov 9, 2010

Should I declare the _mcContainer var before the loop or no? (performance increase?)

for(var i:uint = _startIndex; i <= _endIndex; ++i){
var _mcContainer:MovieClip = _mcParent["i_" + _position];
}

[Code]....

View 1 Replies

Declaring Variables In Flex?

Feb 25, 2011

I found this in an ActionScript class in flex.

protected::valueMin know what this exactly means. at the outset, I dont see any type declaration. I am a newbie in flex.

View 2 Replies

ActionScript 3.0 :: Declaring Variables Only Once

Dec 27, 2009

I have a simple math game where the user enters his answer and clicks a button. The problem I am having is that if the answer is wrong, the numbers in the question do not change on the screen but but in the actionscript, the variables being used to check the answer change. How do I get the variables to stay the same when the user's answer is wrong? Not redeclare all of the variables.

Code:
var num1:uint = Math.Random()*1000;
var num2:uint = Math.Random()*1000;
var sum1:uint = num1 + num2;

[Code].....

View 1 Replies

ActionScript 3.0 :: Declaring Multiple Variables?

Dec 21, 2011

I want to declare on multiple numerated variables like this:
 
var myVar1;
var myVar2;
 
But I don't want to do this manually for every variable instance but automatically, so I need a way to instruct the compiler to declare by himself on every variable and to numerate them automatically.
 
So hopefully I explained myself well, I wanted to know if there is such way to do this?

View 2 Replies

ActionScript 2.0 :: What Rules Are For Declaring Variables

Sep 17, 2007

I was wondering what the rules are for declaring variables which you would increment say in an for loop. I tried to declare a variable outside the for loop, and then increment it within the loop but that didn't work.

View 2 Replies

ActionScript 3.0 :: Declaring And Naming Arrays In A Loop Possible?

May 12, 2009

Is there a way to do this somehow?

Code:
var someVariable:int = 3;
for(var i:int = 0; i< someVariable; i++){
var mainArr[i]:Array = new Array();//I get an error if I try this

[Code]....

View 6 Replies

ActionScript 3.0 :: Declaring New Variables Within A Switch Statement?

Oct 10, 2009

does anyone know if declaring new variables within a switch statement (inside of case: break actually creates new variables inside those switch statements, or are the variable declarations moved to the top of the function when compiled?

i know that when declaring new variables inside a for or while loop, the compiler declares those variables at the beginning of the function. is it the same for if or switch statements?

View 3 Replies

ActionScript 3.0 :: Declaring Variables Inside Function And Use Outside?

Feb 25, 2010

I know that as long as a I declare variables inside a function I can only call them as long as the scope of the function is active. Outside of that function the variables don't exist. Is there any way I can create those variables inside a function and use them outside of it?

View 1 Replies

ActionScript 2.0 :: Declaring Global Variables Possible With Scripting?

May 27, 2002

i am wondering where and how i can insert global variables in my code (below)....or is that too 'C' a concept!?!...see what i am trying to do here is this...onClipEvent calls within it attachMovie from my library with the appropriate linkages...a few setProperty here and there...what i want is a few characters initialised above the rest of the code...why?...coz as u will see, when k=0, a movie is picked up, put at level m=1...

...the second time round the loop begins, k=1 so a movie gets picked up again at random...now this is where i need ur help...the second (and subsequent 3 movies) need to be placed on top of the basemovie...i am trying swapdepths here...good hoice?...anything else i can do?...yet to figure out reducing the opacity of subsequent movies...see i am looking for a motion trail kinda effect...so at one point of time 5 mc will be visible...total no. of mc=250 and at random they get picked up over and over again...

[Code]....

View 8 Replies

ActionScript 2.0 :: Correct Syntax For Declaring A Variable Within A Loop?

Mar 25, 2007

Whats the correct syntax for declaring a variable within a loop? Something like this:[code]

View 1 Replies

ActionScript 3.0 :: Declaring Public Arrays Inside For Loop?

Oct 26, 2009

I'm trying to declare arrays inside a for loop, then access them later as if they were declared publicly/globally. This doesn't work:

Code:
playlist = addChild(new MovieClip());
playlist.header = new Array();
for (i=0; i<3; i++) {
playlist.header[i] = playlist.addChild(new MovieClip());
or (j=0; j<6; j++) {
[Code] .....

How would I declare the arrays within the for loop, but still access them later without them becoming undefined?

View 2 Replies

ActionScript 3.0 :: Quick Method For Declaring Multiple Variables?

Apr 30, 2011

I am writing a program that requires the use of 36 boolean variables with different names (e.g. box1, box2...): does anyone know of a quick way to optimize this program.

View 5 Replies

ActionScript 3.0 :: Declaring Variables In A Sub Class But Using Them In The Base Class Constructor?

Sep 20, 2009

I am creating a Weapon class for a game and the weapons itself will be the sub classes. The sub classes will hard code some values (such as max ammo and the weapon name).

I trying to access this declared data in the base class constructor, at the moment it's not outputting the values. Is this possible?

I've broken my Weapon class for simplicity:

ActionScript Code:
package
{
import flash.display.MovieClip;

[Code]....

My current workaround is creating a protected method in the base class to trace the information and calling that method in the sub class's constructor, this works fine but this doesn't seem like the most efficient technique?

View 7 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

ActionScript 3.0 :: Possible To Use A For Loop On Two Variables At Once?

Jan 23, 2011

Is it possible to use a for loop to "combine" array variables..g.

Actionscript Code:
var myArray1:Array = [1, 2, 3]; var myArray2:Array = [1, 2, 3]; for (var i:Number in myArray1 && var i:Number in myArray2) //is something like this possible? { ...

[code].....

View 4 Replies

Get Dynamic Variables In For Loop?

Jan 1, 2011

How am i to get the variables zombData.zomb0, & zombData.zomb1 from inside the "for loop"

I want this trace command dynamic

Quote: trace(zombData.zomb+i);

it works when i put zombData.zomb0 (a variable sent from a PHP script)but if i want to make it dynamic how it is; It fails & outputs NaN How do i make it dynamic for the loop?[code]...

View 1 Replies

ActionScript 2.0 :: For Loop Variables?

Jan 5, 2010

I have 24 movie clip buttons. Named "btn1" through "btn24". I can't figure out how to return the variable as a number that cooresponds to each button onRollOver.

[Code]...

View 2 Replies

ActionScript 2.0 :: Getting Variables Out Of A For Loop?

Jan 2, 2011

i'm trying to use a for loop to generate for me a set of vars, but it's not really working out. =.=.

I'm loading the image file names from a xml, and i want that the for loop create vars like "fotoToLoad0, fotoToLoad1 ..." and load the filename within.

I guessed i had to use the eval command, but as far as my ignorance sees it, when it is used, the eval makes a variable reffer to another and not fill it's value. (I guess i'm wrong thou).

Here's what i've tried so far:

Code:
for (i=0; i< totalNodes; i++){
var fotoEnd = imagesXML.firstChild.childNodes[i].firstChild.firstChild;
var fotoTemp = eval ('fotoToLoad'+i);
fotoTemp = fotoEnd;

That's quite not working thou =(. If i try used 'fotoToLoad1" for example, in a text box it just returns undefined

View 2 Replies

ActionScript 3.0 :: Setting Variables In A FOR Loop?

Apr 23, 2009

I used to dynamically set some variables using a FOR loop kinda like so PHP Code:

//Sorry, from memory
var possibleValues:Array = ["red","green","blue","yellow"];
for (i=0;i<possibleValues._length;i++){
_root["colorNumber"+i] = possibleValues[i];
}

Second question, using that code in a function would set the variables at the root level making them available throughout the timeline. Without "_root" how do I get that variable available to everything?

View 7 Replies

Creating Variables Dynamically Within A For Loop?

Jan 24, 2010

I need to make new sprites on-the-fly within a for loop, and this code does not work:

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

[code].....

View 2 Replies

Actionscript 3 :: Getting The Right Variables In A Foreach Loop?

Dec 20, 2011

I'm trying to get specific variables out of a for each loop. These variables are used to display a click event on a marker on a map. If you click the marker on the map, the details pop over it. Now these details are being overwritten each time the loop starts (50 times). The solution I'm looking for, let's me select a marker on the map with the according detail attached to it.

There might be an easy solution but I haven't found it yet.

The code : for each(artistXML in artistList.events.event)

[Code]...

View 1 Replies

ActionScript 3.0 :: Accessing Variables In A Loop?

Sep 9, 2009

i'm having trouble creating an image preloader with a loop. my apologies, this might be a very simple task that i've been pulling my hair out over for an hour.

i have 8 UIloaders. each named image1,image2,image3, etc. they are inside a movie clip called "allClips_mc".

this VERY long, redundant code works:

Code:
magicBox_mc.allClips_mc.n1.image1.source = "newsClips/images/newscast01.jpg";
magicBox_mc.allClips_mc.n2.image2.source = "newsClips/images/newscast02.jpg";
magicBox_mc.allClips_mc.n3.image3.source = "newsClips/images/newscast03.jpg";
magicBox_mc.allClips_mc.n4.image4.source = "newsClips/images/newscast04.jpg";

[Code]....

View 2 Replies

ActionScript 3.0 :: Sum Of Variables Expressed With For Loop

Oct 6, 2010

ActionScript Code:
var val1:Number = 10.80;
var val2:Number = 11.54;
var val3:Number = 12.22;
How would I express this in a loop?
var sum:Number = val1 + val2 + val3;

View 3 Replies

ActionScript 2.0 :: [MX] - Defining Variables In A For Loop?

Feb 15, 2005

Here's what I've got:

var cColor1:Color = new Color(mcBut1.mcFill);
var cColor2:Color = new Color(mcBut2.mcFill);
var cColor3:Color = new Color(mcBut3.mcFill);
var cColor4:Color = new Color(mcBut4.mcFill);
var cColor5:Color = new Color(mcBut5.mcFill);

What I'd like to do is write a loop to handle all that code in less code. So, how do I define variables using variables?

Something like:

for (var i:Number = 1; i < 6, i++) {
var cColor+i = new Color(eval("mcBut"+i).mcFill);
}

View 2 Replies

ActionScript 2.0 :: Loading Variables In A Loop?

Apr 26, 2002

I've a .txt-file containing variables. The variables are structured like this:

aaa_301, bbb_301, ccc_301
aaa_302, bbb_302, ccc_302
...

[code]....

View 9 Replies

IDE :: Complex Loop CurrentTarget Variables

Feb 1, 2010

i'm trying to create a menu system where each item expands in height when clicked but is then collapsed back to the original state when other items are clicked.m is the height of the expanded state. n is the height of the collapsed state. i is the number tacked on the instance name.Also, I'm using Tweener for smoother transitions. I've done this already by copying out the code but it's 24 items so 24x24 lines of code when I'd like to be able to do it a little more elegantly. Here's roughly what I want to do, but don't know if it's possible:[code]So every box below the one that's been clicked on most recently gets the value of m added to the y value and every box above doesn't.Is it possible to retrieve the value of the variable i that corresponds to the currentTarget?

View 1 Replies

ActionScript 2.0 :: [FMX] Scope Of Variables In Loop?

Apr 11, 2005

Code:
var x:Number = 0;
var y:Number = 0;
var i:Number = 1;

[Code]....

i have no access to y in the (x < 600) loop... yet i gets incremented every loop.

View 2 Replies







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