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

Feb 15, 2005

Here's what I've got:

[Code]...

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?

[Code]...

View 2 Replies


Similar Posts:


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 :: 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 :: Defining For Loop Iterator Before The For Loop?

Jun 2, 2011

Recently I'd been criticized for structuring my for loops like so:

var i:MovieClip;
for each(i in array)
{

[Code]....

This reads better for me personally, yet I'm being attacked for it. Is there any difference?

View 2 Replies

ActionScript 2.0 :: Defining And Using Variables?

Mar 12, 2004

I posted a problem recently and I think I was asking too much too soon, I apoligise for that one. I want to try again with my problem. Basically I am making an interactive circuit builder in flash mx for 8-10 year olds (does anyone remember crocodile clips?).

[Code]...

View 8 Replies

ActionScript 2.0 :: MovieClipLoader And Defining Variables?

Apr 28, 2008

using the MovieClipLoader function to load in several images into various actionscript defined movieclips. These movie clips, with images loaded into them, are going to have onRelease functions associated with them which will load in a larger version of the image already loaded. As you can picture, there are a series of thumbnails, and each thumbnail needs to be clickable and load a larger version of itself into an empty clip. However, I can't seem to define variables inside of the MovieClipLoader object as it's not technically a movie clip?

How might I know which larger file to load when one of the thumbnails is clicked? All the files are named all sorts of things, aren't in any particular order (user defined from a drag-n-drog UI)... I thought I was on the right track, until I realized I couldn't define variables within the empty clip holding the thumbnails..

View 2 Replies

ActionScript 2.0 :: Defining Variables In A Function?

Apr 19, 2005

Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:

Code:
//define the function
function attachVid(nc, ns, curVid, vidFile) {

[Code].....

I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv's on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn't seem to be working.

View 1 Replies

ActionScript 1/2 :: Defining Variables From A Separate Timeline?

Jan 17, 2011

I'm having a strange problem setting variables in movie clips from another (parent timeline). I run the following code from the parent movie clip to target child movie clips it contains.

setVars = function (clip, value) {
clip.val1 = value;
clip.val2 = 0;

[Code].....
 
I am trying to set variables in a movie clip targetted by the 'clip' argument in the setVars function but they are being traced as undefined. However, setting the function works fine. I have also tried manually defining the variables in the movie clip and am still unable to change them externally from the setVars Function.

View 3 Replies

ActionScript 3.0 :: Defining Variables From Parent In Child

Mar 8, 2012

im working with my main FLA and a script for it child.as i have created a variable in the parent, "svar:Number = 0;" i would like the child to be able to modify this variable when certain triggers are met i've tried something like this in the "child.as" but im assuming its probably much more complicated

[Code]...

im wondering if there is a simple command such as this to call upon an existing variable in the parent? if not, is there a way i can import the variables using the import command?

View 9 Replies

ActionScript 2.0 :: (Flash CS3) Defining Variables To Different Buttons?

Nov 24, 2010

I'm trying to assign actions to various buttons for a website I am building, however I would also like to play a little movie first each time before linking to their individual different frames. The movie is the same for each button but then, obviously each button ultimately needs to link to a different frame. I'm guessing a nifty mix of gotoandPlay and variables are the answer but I'm getting myself in knots.

The structure of the site is as follows.On the main stage I currently have 4 frames. Each frame contains a different "page" of the website. The "home" frame has the navigation bar (including a sub-menu movie which has a number of buttons nested inside it which I think is going to be tricky). At the end of the "home" movie, there is a little fade animation which is labeled/ red flagged on the timeline - and it's this little animation I would like to have playing when a button is clicked on before linking to another frame.

At the moment the best I can manage is that when the button is clicked it goes back to the beginning of it's movie (a problem with the target paths perhaps?) as opposed to a label within the parent movie.I also think where I'm getting confused is exactly where I am supposed to define all the various variables and pieces of actionscript. The little snippits of code I have are as follows: Within the button I am trying to link, so far I have:

on(release){
_level0.frame_to_goto = "artwork";
play();
}

The "artwork" tag is the frame specific to that button (this is one of the sub-buttons that is nested within a submenu movie).Then in the movie for the webpage I have the following in the last frame of the mini animation that I want to play before the button links to the artwork frame:

stop();
if(_level0.frame_to_goto != undefined){
_level0.gotoAndPlay(_level0.frame_to_goto);
}else{
trace("An error as occured!");
}

View 7 Replies

ActionScript 1/2 :: Defining Actions For Buttons Inside A For Loop?

Jan 8, 2011

I got a set of buttons and  a text  field where they load the content.I'm trying to not make one zillion functions and keep the code neat so i  guessed i would try set the buttons' actions within the loop too. I firstly had  some problems getting the i counter inside the onRelease function (actually I  don't think i ever got how to do it). But I tried this and worked:

stop();var comprarXML = new XML();comprarXML.ignoreWhite = true;comprarXML.load('flash/comprar.xml');comprarXML.onLoad = checkLoading; function checkLoading(success) { rootNode = comprarXML.firstChild; ButtonReleaseAndContent ();} function ButtonReleaseAndContent (){ for (i=0;i<12;i++){   // my buttons are not generated dynamicly, that  why the count. btTemp =

[code]....

At the line where I set the text, I had a though " I may have to  refer from within the button mc, since the generated code goes inside it!". So i  tried the this.temp , guessing that this would be equal to the button level. A  few seconds later i noticed my referencing for the text field wasn't coming from  within the button, but from the root.

View 3 Replies

ActionScript 2.0 :: Defining Variables For Buttons For Next Movie To Load?

Jun 28, 2005

I�m planning to make a magazine in Flash, and I would have to load several pages of it in order. But I�d like to put the buttons forward and previous on the main movie and make then load each page in a container.Is there a way to set variables for each page so the main movie "knows" what movie is loaded at the moment and what page it has to load next.

View 5 Replies

ActionScript 3.0 :: Defining Values Of Variables For Classes, Subclasses, And Instances?

Jan 5, 2010

how subclasses,instances,and inheritance work. The below code isn't actual project code, it's theoretical code, generalized to a simplistic level so that we can talk about the big issues.Let's say I have animals_app.fla, with a "Dog" class MC and a "Cat" class MC. Both "Dog" and "Cat" are subclasses of "Animals"; animals_app.fla uses document class "Main".

Intuitively, I think Animals should declare that every subclass should have some animalSpecies, and each subclass will define the value of its own animalSpecies. It wouldn't make sense for Animals to provide any default value, because it will always be different per subclass. Is this correct? I had tried out some code similar to that below, and was perplexed because it seemed like whenever a subclass tried to define a value for its own animalSpecies variable, it was actually changing the value of the variable in the Animal class, but that's not what I want. How do I rewrite this code so that each subclass defines the values of variables it inherits from its superclass, without altering the superclass? And how would I define the value of variables for each instance of a class, so that I'm only changing the values of that instance, without altering the subclass?

Animals.as

Code:
package
{
import flash.display.MovieClip;[code]..........

Also, conventionally, what should be in my Main class? Only the addChild code which attaches MCs to the stage? Or should the values of variables be defined in Main? What am I missing? I recently read Foundation Game Design with Flash and didn't feel like the explanation was sufficient. I've tried scouring the web for OOP tutorials, but they're either too basic or too far over my head.where I should be defining values of variables for classes, subclasses, and instances?

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

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

ActionScript 2.0 :: Variables In For Loop Renamed?

Apr 18, 2005

i wanna create a photo album.this is thumbs page.

Code:
for(i=0;i<2;i++){
this.createEmptyMovieClip("logo_mc"+i+"", 999);
loadMovie(""+i+".jpg", logo_mc+i+);
}

how can i solve this problem about variables??

View 5 Replies

ActionScript 2.0 :: CS3 - Array Loop To Change Variables?

Sep 4, 2010

The plan is to set up variables to react to a flashvars value like this:

[Code]...

There would be many mainVars (over 100, actually) and this setup isn't working.

View 1 Replies







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