Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Adding Variables From Duplicated Mc's



ok so i'm using MX but developing for 5.
what I'm trying to do is create a flash form for media buys.
the row of input text is a mc and when you hit the + button it duplicates for the next set of info.
At the bottom is a TOTALS list that needs to calculate all the costs above and keep updating each time new info is added.

can someone please help me out with this? I don't know how to script in how to keep adding new mc's into the totals section.

I hope I'm being clear enough and if not please ask me for more details. I'm semi-desperate

you can
get the zip file here
or
get the fla alone
or
get the swf alone

and Please email me at brad@goofydawg.com if you have comments/answers
AIM: BradFlower
ICQ: 11767987

THANKS to all for even looking at this... DOUBLE thanks if you help!!!



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-09-2002, 01:58 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Adding Actions To A Duplicated Movieclip
Hi

I have to duplicate a rectangle movie clip that I have and then put different actions on them. My code can't seem to do it. It doesn't even do the onLoad function... Help me please. Thanks


Quote:





// this is on frame 1

_root.speed = 10;

// duplicate the rectangle which is outside the stage
rect.duplicateMovieClip("rect1",1,{_x:400,_y:350}) ;

_root.rect1.onLoad = function() {
oldX = this._x;
oldY = this._y;
toX = 150;
toY = 150;
}

_root.rect1.onEnterFrame = function() {
this._x += (this.toX-this._x)/_root.speed;
this._y += (this.toY-this._y)/_root.speed;
}

stop();

Adding Code To Duplicated Movie Clips
Hi,

I have a movie where I use this code to duplicate a movie clip:

for(var i:Number = 0; i < 7; i++){
_root.item_mc.container_mc.attachMovie("redscarfSy m", "redScarf" + i, container_mc.getNextHighestDepth());
}

This (I think) allows me to create multiple copies of the same movie clip on the stage, each with a different name.

I want to be able to drag them. Does anyone know how to account for the variable? I've tried this

"redScarf + i".onPress = function() {
this.startDrag();
};

Which doesn't work.


Thank you for your help.

Adding Code To Duplicated Movie Clips
Hi,

I have a movie where I use this code to duplicate a movie clip:

for(var i:Number = 0; i < 7; i++){
_root.item_mc.container_mc.attachMovie("redscarfSy m", "redScarf" + i, container_mc.getNextHighestDepth());
}

This (I think) allows me to create multiple copies of the same movie clip on the stage, each with a different name.

I want to be able to drag them. Does anyone know how to account for the variable? I've tried this

"redScarf + i".onPress = function() {
this.startDrag();
};

Which doesn't work.


Thank you for your help.

Adding ActionScript To A Duplicated Movie Clip?
I am duplicating a button with the following code

duplicateMovieClip (button_user, "button_user2", 1);

I want to put code on this duplicate that is different from the code on the original. Is this possible?

For Example say the button_user button has this code on it

on (rollOver) {
gotoAndPlay (2);
}

Can I give the duplicate "button_user2" this code

on (rollOver) {
gotoAndPlay (3);
}

I am not sure if this is possible... If not is there another approach that I should take?

Trouble Adding Duplicated Movieclips To Array
whats up everybody,

once again its almost time to choke the young'ns. I'm on my last nerve and someone or something is gonna catch the wrath.

i have a question or problem that seems easy enough to handle. i've been trying to store my duplicated movie clips inside an array so i can access the x and y positions later. i have duplicate about 20 movie clips and need to have their names stored in an array while they're being duplicated. here's what my code looks like so far:

var intervalID;
intervalID = setInterval(checkLoadStatus, 100);

function checkLoadStatus() {
if(Title.loaded){
clearInterval(intervalID);

//split artist string into array
aArtists = Title.artists.split(",");
aPhotos = Title.photos.split(",");

// initialize stars with Title data
star_amount = aArtists.length;
trace("XXstar_amount = " + star_amount);



//declare arrays
a_Stars = new Array(star_amount);
a_centerCheck = new Array(star_amount);


for (i=0; i<star_amount; i++){

a_Stars[i] = duplicateMovieClip("star", "star" + i, 1+i );

//set length of array
a_Stars[i] = this["star" + i];

//set boolean values to check for position
a_centerCheck[i] = false;

}
star._visible = false;
trace("AAthe elements in a_Stars: " + a_Stars[1]._name);
trace("ZZthe elements in a_centerCheck: " + a_centerCheck[5]);
}
}


the problem is that flash is not storing the elements of the array. on my trace command a_Stars array keeps coming up empty while a_centerCheck displays its elements all fine. stars(the duplicated movie clip) is a child so the target is i believe to be ok. (but is probably wrong also - i just don't know).
any help, as always, is greatly appreciated.

thanks
erase

Adding Unique Dynamic Text Fields To Duplicated Movieclips
Hey All,

I'm working on a piece for work. I need to figure out how to add unique dynamic text fields to duplicated movieclips. Unique as in unique instance names and variable names. Thanks for any help that anyone can provide.

I have a movieclip on the stage that contains a dynamic text field.

the text field will house text that is being pulled from an xml file.

What I need is to have the dynamic text field in all the duplicated movieclips have a unique instance name and variable name.

I assume that a nested for loop would be required, but I'm not sure as I am not the greatest actionscripter. Here's what I have so far:

myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {

// populate the amount of rows based on the amount of nodes
rows = this.firstChild.childNodes.length;

// enter how many columns are needed
columns = 3;

// starting position of the first movieclip (holder)
xpos = 20;
ypos = 20;

// spacing between each holder
vspace = 1;
hspace = 10;

// the width and height of the holder movieclip
wclip = holder._width;
hclip = holder._height;

// counter
theclip = 1;

// make the grid
for (var i = 0; i<rows; i++) {
for (var j = 0; j<columns; j++) {
var thegrid = holder.duplicateMovieClip("holder"+theclip, theclip+1);
thegrid._x = xpos+((wclip+hspace)*j);
thegrid._y = ypos+((hclip+vspace)*i);
theclip++;
}
}
}
myPhoto.load("thumbnails2.xml");

Duplicated MC And Variables
Hi, i duplicated a MC which only contains a dynamic text field and its VAR name set to "txt".

Then i used a php script to set the value of the text fields of the duplicated MC...and it donesnt work.

I figured out it must be something with the duplicated MC because the original MC seems to work fine.

Lets say i used this code (php)

print "_root.mc.txt=hello";
"mc" is the original one and it works fine but if i use

print "_root.mc1.txt=hello";
"mc1" is the new name given to the mc when duplicated. This doesnt work.....

Dynamic Variables In Duplicated Mc?
I´m new to Flash 5 actionscript so I can´t understand why this won´t work;


i = 0;
while (i<3) {
i = i+1;
clip.duplicateMovieClip("clip"+i, i);
setProperty ("clip" + i, _x, x + i);
setProperty ("clip" + i, _y, y + i);

}


The thing is the dynamic named clips works but not the dynamic positioning ( x + 1 etc)
How do I get clip1 to position at x1 y1 and clip2 at x2 y2 ?!?!?
Please help me! I´m bot a programmer but this can´t be so hard...?!

/Thanx

Updating Variables Of Duplicated Mc'c ... Plz Help
the link:

lutz22.org
pw: 2fat2****

nav -> shop
can't get the damn basket working properly ...

my you can give me a suggestion ...

thanx

Variables From Duplicated Movies
catching variables from duplicated movies seems cool in flash 5 -

if (_root["mc" add i].variable==value){

but how is this done in Flash 4?

instead of /main:variable i want to say /"mc" add i:variable.

it really is amazing what you forget isn't it?

cheers all

beezer

Define Variables Of Duplicated Mc's
here's the basic concept of my problem.
I have an mc on the stage called "shot".
This is the script on that mc:

onClipEvent (enterFrame) {
_x+=xmov
_y+=ymov
}

I want to duplicate it and give different values to xmov and ymove.
I did this to duplicate it:

duplicateMovieClip("shot", "shot" add shotname, shotname);

What shoud i do next?
please help me. thank you

Duplicated Text MCs And Variables
I am trying to create a looping display text. The goal is that each loop creates a new MC and the MC shows a specific variable (or array element).

I have tried this with text buried in an MC, actionscript created text boxes... precreating the needed MCs and then placing them... nothign works

This variation creates the MCs at the right time, but the text area always displays the current variable... I think it comes down to binding the variable to the item, but for the life of me, I can't get it to work - and I knwo I have done it somewhere before!


Frame 1

//set current jump to 0, set max jumps
nowJump = 0;
maxJumps = 5;
//item count
item = 0;
//walls
boxL = 0;
boxB = 566;
boxR = 35.4;
boxT = 0;

// sub texts
var subText = new Array();
subText[0] = "http://";
subText[1] = "html";
subText[2] = "internet";
subText[3] = "actionscript";
subText[4] = "www";
subText[5] = "php";
subText[6] = "Flash";

//fianl locations
var finalX = new Array();
var finalY = new Array();
finalX[0] = 24;
finalY[0] = 212;
finalX[1] = 0;
finalY[1] = 0;
finalX[2] = 0;
finalY[2] = 0;
finalX[3] = 0;
finalY[3] = 0;
finalX[4] = 0;
finalY[4] = 0;
finalX[5] = 0;
finalY[5] = 0;
finalX[6] = 0;
finalY[6] = 0;


Frame 2: JumpsStart

// number of jumps
jumps = Math.ceil(Math.random()*maxJumps);
duplicateMovieClip(subTextBox, "subTextBox"+item, item+1);
currBox = "subTextBox"+item;


Frame 3:JumpTo

// random X and Y
jumpX = Math.round(Math.random()*(boxR-boxL))+boxL;
jumpY = Math.round(Math.random()*(boxT-boxB))+boxB;
eval(currBox)._x = jumpX;
eval(currBox)._y = jumpY;
// set content
-->>> this si where I need to set the content and nothing works


Frame 7

if (nowJump <= maxJumps){
gotoAndPlay("jumpTo");
nowJump++;
}
else{
eval(currBox)._x = finalX[item];
eval(currBox)._y = finalY[item];
play();
};


Frame 11

item++;
gotoAndPlay("jumpStart");

Duplicated Text MCs And Variables
I am trying to create a looping display text. The goal is that each loop creates a new MC and the MC shows a specific variable (or array element).

I have tried this with text buried in an MC, actionscript created text boxes... precreating the needed MCs and then placing them... nothign works

This variation creates the MCs at the right time, but the text area always displays the current variable... I think it comes down to binding the variable to the item, but for the life of me, I can't get it to work - and I knwo I have done it somewhere before!


Frame 1

//set current jump to 0, set max jumps
nowJump = 0;
maxJumps = 5;
//item count
item = 0;
//walls
boxL = 0;
boxB = 566;
boxR = 35.4;
boxT = 0;

// sub texts
var subText = new Array();
subText[0] = "http://";
subText[1] = "html";
subText[2] = "internet";
subText[3] = "actionscript";
subText[4] = "www";
subText[5] = "php";
subText[6] = "Flash";

//fianl locations
var finalX = new Array();
var finalY = new Array();
finalX[0] = 24;
finalY[0] = 212;
finalX[1] = 0;
finalY[1] = 0;
finalX[2] = 0;
finalY[2] = 0;
finalX[3] = 0;
finalY[3] = 0;
finalX[4] = 0;
finalY[4] = 0;
finalX[5] = 0;
finalY[5] = 0;
finalX[6] = 0;
finalY[6] = 0;


Frame 2: JumpsStart

// number of jumps
jumps = Math.ceil(Math.random()*maxJumps);
duplicateMovieClip(subTextBox, "subTextBox"+item, item+1);
currBox = "subTextBox"+item;


Frame 3:JumpTo

// random X and Y
jumpX = Math.round(Math.random()*(boxR-boxL))+boxL;
jumpY = Math.round(Math.random()*(boxT-boxB))+boxB;
eval(currBox)._x = jumpX;
eval(currBox)._y = jumpY;
// set content
-->>> this si where I need to set the content and nothing works


Frame 7

if (nowJump <= maxJumps){
gotoAndPlay("jumpTo");
nowJump++;
}
else{
eval(currBox)._x = finalX[item];
eval(currBox)._y = finalY[item];
play();
};


Frame 11

item++;
gotoAndPlay("jumpStart");

Variables Of Duplicated Textbox/MC's
Hey

If i have a MC which contains a textbox say with variable myTEXT assigned to it, when i duplicate this text box how do i call the variable for each textbox there after?

Thanks

Sending Variables To Duplicated Movies
I've got a script which is duplicating movies OK.

They're called "square_" + n

and I'm trying to send a variable to each one so that it can display it's number in a text field ("data")

If I send a variable to the movie when the variable isn't an
expression, i.e.

data = "n";

then this string goes to the duplicated movie I want, when I want

but if I want to send a variable

data = n;

then nothing happens. Is this because the duplicated movie can't see the variable? Is there a way to send this data to the duplicated variable?

heres to hoping,

tom

Pass Variables To Duplicated Movieclips
hi, i have a problem with a template i am making, the use of it is to load a timer for a cyber cafe, but i want it to load as many buttons as i say in a txt file, everything is ok up to the point where i want to give each button a number, the main button has a text field where i want the number, but i have noticed that if i give any created instance a variable number, the rest get the same, any idea of how can i get around this?
here's the code i used, but i don't know what can i do next.

loadVariablesNum("data.txt", 0);
_root.onEnterFrame=function(){
for(i=2;i<varcabs;i++){
duplicateMovieClip(mc1,"mc"+i,i);
setProperty ("mc"+i, _x, (31*i)-6);
setProperty ("mc"+i, _y, 362);
}}

maybe if someone wants to check the fla...

Passing Variables To A Duplicated Movie
just wondering if theres a way to pass variables to a duplicated movie.
Ill be creating duplicate movies very fast (about 20 per second)
and want them each to have differrent variables to work with.

duplicating with that , and i want to pass 3 variables to the new movie clip

dot.duplicateMovieClip("dot"+currdot, this.getNextHighestDepth(), {_x: xpos, _y:ypos});

Passing Variables To A Duplicated Movie
just wondering if theres a way to pass variables to a duplicated movie.
Ill be creating duplicate movies very fast (about 20 per second)
and want them each to have differrent variables to work with.

duplicating with that , and i want to pass 3 variables to the new movie clip

dot.duplicateMovieClip("dot"+currdot, this.getNextHighestDepth(), {_x: xpos, _y:ypos});

Unique Variables In Duplicated Clips
Code:
onClipEvent(load)
{
this._x=_root.fish._x;
this._y=_root.fish._y;
speed=13;
if(_root.fish._x>_root.fish2._x)
{
_xscale=-(_xscale);
this.missileright=0;
}
else(_root.fish._x<_root.fish2._x)
{
this.missileright=1;
}

}
onClipEvent(enterFrame)
{

if(this._x>_root.fish2._x)
{

if(this.missileright==0)
{
this.missileright=0;

}
else if(this.missileright!=0)
{
_xscale=-(_xscale);
missileright=0;
}

this._x-=speed;
}
else if(this._x<_root.fish2._x)
{

if(this.missileright==0)
{
this.missileright=1;
_xscale=-(_xscale);
}


this._x+=speed;
}


if(this._x>505)
{
this._x=0;
}
else if(this._x<-5)
{
this._x=500;
}
if(this._y>_root.fish2._y)
{
this._y-=10;
}
else if(this._y<_root.fish2._y)
{
this._y+=10;
}
if(this.hitTest(_root["fish2"]))
{
this.removeMovieClip();
}

}


Also when you hit insert and shoot the fish missle sometimes it comes out the right direction and sometimes it doesn't(this only happens if the red fish is moving, the controls for the red fish are A and D), it should not vary, I can't figure it out. Its going by the missileright property of the parent clip and not the property of each child clip, how do I change this? Here's the URL:


fish

Passing Variables To A Duplicated Movie Clip?
Ok, let's say that I make a movie clip on the stage that has actionscript on frame 10 that moves the clip across the screen from left to right. Inside the clip is a little bit of actionscript that also tells the clip how fast to move depending on the variable 'speed'.

Now, in the main timeline I make 5 more copies of that clip with duplicateMovieClip. Let's say they are called move1, move2, move3, and so forth. To move which clips I want in actionscript on the main timeline, I just put in something like move3.gotoAndPlay (10);. To set the speed for ALL movie clips I just type in a global variable for speed like _global.speed = 5;

Ok, that all works fine and dandy, but what if I want to send a different speed to each movie clip. Making a global speed variable would change the speed for all of them, and since I am using duplicatedMovieClip to make the extra clips, they will all use the same variable (speed) to control how fast they move across the screen. Is there a way I can pass a different variable that speed might equal for each seperate instance?

Creating And Setting Variables In Duplicated Movie?
Hi,

I am working on a thumbnail gallery which is dynamically generated. At the moment I am taking this approach:

1. I load a variable from a txt file that represents the total number of thumbs to generate and via a for statement I have the thumbnails generated:

Code:
for(i=0; i<_root.aantal_tekst; i++) {
_root.t++;
duplicateMovieClip("_root.thumbtemplate", "thumb"+_root.t, _root.t);
loadMovie(_root.thumbfolder+"pic"+_root.t+".jpg", "_root.thumb"+_root.t);
}
However, now I want to set a variable so when clicking on the generated thumbs it actually opens the bigger sized picture.

I tried creating and setting the var via set Variable but somehow it doesn't do the trick.

I'm a completely off when thinking to use set Variable? Is tehre another way to do this? Or, can someone give me a pointer as to how to deal with this?

If you need more info just let me know.

Thx in advance!


kind regards,

RF

Pass Variables To Duplicated Movie Clips
I am working on a XML based photo gallery that loads 16 images into thumbnails. The concept is to have the thumbnails be buttons that change an image that is located on the left.

This image is changed using a LargeImg(x) function, where x is an image inside an array.

I have two movie clips:
1.Thumb which is duplicated 16 times and replaced with images
2.ThumbButton which is duplicated 16 times as well, ontop of Thumb.

ThumbButton has a transparent button located inside that runs _root.LargeImg() function. I need to pass a value to the duplicated ThumbButton mc, that will enable the LargeImg() function to well, function.

How do I do that?

I hope that explains the issue.

Thanks for the help!

Passing Variables To A Duplicated Movie Clip?
Ok, let's say that I make a movie clip on the stage that has actionscript on frame 10 that moves the clip across the screen from left to right. Inside the clip is a little bit of actionscript that also tells the clip how fast to move depending on the variable 'speed'.

Now, in the main timeline I make 5 more copies of that clip with duplicateMovieClip. Let's say they are called move1, move2, move3, and so forth. To move which clips I want in actionscript on the main timeline, I just put in something like move3.gotoAndPlay (10);. To set the speed for ALL movie clips I just type in a global variable for speed like _global.speed = 5;

Ok, that all works fine and dandy, but what if I want to send a different speed to each movie clip. Making a global speed variable would change the speed for all of them, and since I am using duplicatedMovieClip to make the extra clips, they will all use the same variable (speed) to control how fast they move across the screen. Is there a way I can pass a different variable that speed might equal for each seperate instance?

Setting Variables In Dynamically Created (duplicated) Movie Clips
How do I set a variable in a dynamically created movie clip? Here's the code I used to duplicate the movie clip:

code:
missileCounter++;
_root.missile.duplicateMovieClip("missile"+missile Counter, missileCounter);


I used the setProperty() method to set properties like X and Y positions, but I don't think you can use that for variables, can you?


Thankyou for any help!
Rick

Flash MX Problem Addressing Variables In Duplicated Movie Clips
Help!

I'm having problems sending variables into duplicated movie clips. I'm using Flash MX.

The source variables are in the main timeline, as is the original source movieclip, which is not an external swf, it is inside the main movie. The data loads in from a textfile, and has a variable at the end to prevent anything happening until its finished loading.

e.g.
totalpeople=3&
&
entry1name=derek&
entry1age=34&
&
entry2name=steve&
entry2age=32&
&
entry3name=johanna&
entry3age=34&
&
loaded=yes


Now here's the catch

I have a loop which generates copies of a movieclip, these are called person1, person2 etc

after creating each - the script then needs to set variables within each one based on the text file values already loaded (see above).

Each duplicated movie clip has variables inside it called;
name
age

so a sub loop attempts to set the values within the duplicated movieclip

for (item=1;item<_root.totalpeople+1;item++){

//address mc object first to have its variables set
thetarget="_root.person"+item;

//what is value from _root to put into mc?
thevalue="_root.entry"+item+"name";

//change the variable
changeitc.(eval("thetarget.thevalue"));

// and so on for the other variables

}


It seems to have problems with the . after the "changeitc.(eval" part of the code.


I have even tried to address the whole thing with one eval statement:

thevalue= "_root.person"+item+".name="+"_root.entry"+item"+" name";
changeit=eval(thevalue);

But still nothing happens... and before you ask - yes, the characters are embedded in the dynamic text fields inside the original "person" movieclip that is duplicated.

Anyone have any ideas why either of these approaches arent working?

Regards

Derek

Adding Variables To Variables In An If Statement
I have a variable named 'Position' which is collecting numbers from various positions, and changeing = 1,2,3 etc.

I want to add 'Position' with its value to other variables:
Sentence, SentenceAnswer ets as seen below.

I have tried as you can see, but it does not work, can anybofy help.

function CheckAnswer(){
if (Sentence+'Position'==SentenceAnswer+'Position'){
_root.Feedback+'Position'=Sentence+'Position'+Corr ect;

}



Cheers

lee

[F8] Confused With Duplicated Bullets And Duplicated Bad Guys...
Hey everyone, I have a (hopefully) quick question.
In a game I have duplicating bullets, and duplicating enemies, I was wondering how I could get the missiles to remove the enemies. thanks in advance!
PJ

Adding Variables
Hi Guys,

just a little question:

I set a variable
abc = 1;

how can I add 1, to get
abc = 2;

thanks in advance
Kasenga

Adding Variables
i need to put the value of a variable on the end of the name of a target but i dont know how.

so i have a variable called "vars" that will be set to a value between 1 and 5. i need the value of "vars" to be placed at the end of the name of the target "cover". that way if "vars" =1 then "cover" will then = "cover1" or "cover2" or "cover3"

can someone help?
thanx

Adding 2 Variables ?
Hi All!
I have to variables in text boxes. Both Numbers. I want to add them as in 3+4=7 ...All i can get to work is 3+4=34...I am using the syntax....

total = variable1+variable2;

it is set as a expression


I think it is something to do with the variables being recognised as numbers...any help would be cool
laters
pixelkid

Adding Variables
Hello. I have set up a quiz with 10 questions. Each question has a variable associated with it. The user answers a, b or c and the variable is set to 1, 2 or 3. I've set up a score_total variable that I want to keep track of the score number and then send them to 1 of three completion screens using an if statement. What I need help with is I can't figure out how to have score_total add and keep track of the numbers from the 10 variables.

The reason I'm not just keeping 1 score variable and adding to it is that the user needs to be able to go back to any question and re-answer it before they complete the quiz.

thanks in advance

Adding Variables?
On release of a button I want a new variable to be created by adding a "name"+["countvariable"]

Giving me for example
if countvariable = 4 it would generate a new variable name4 and the content of a input txt box would be the value

So "name"+["countvariable"]= "input box content"

Any suggestions???

cheers

Adding Variables
This is a simple question, but I need an answer fast.

How do I get the numbers displayed in my dynamic text box to add together. I'm using keypresses for input and keep getting something like 11 rather than 2. If someone could pass along a sample code I'd appreciate it. I know the answer is easy, just can't remember what it is.

Thanks!

-kbob

Adding Variables
Hi people,

i have some variables such as this in the first frame:
PHP Code:



myVar1 = 2;
myVar2 = 5;
myVar3 = 5;




and on frame 200 i want to add them up for a total.
i have tryed to do this like this:


PHP Code:



myVar4 = _root.myVar1 + _root.myVar2 +_root.myVar3




but i cant get it working properly. i keep getting this in the output window:

120 instead of just 12

why is this?

thanks

Adding Variables Together
Please can someone tell me how to add two number variables together.

What I want to do is have two number variables, price1 and price2 to be added together to give totprice.

At the moment, if price1 = 10 and price2 = 15 then totprice = 1015

Please help me!

Thanks

Adding Two Variables Together
I need to add two variables together. This is what I did:

in a mc that I dragged to the stage (frame 100, layer 10 ) I have a variable that if a condition exists then you add 1.. that variable is y and when I list the variable (after the condition exisits) it lists as _level0.instance1.instance4.dragyellow.y = 1

On the next layer I dragged to the stage ( frame 100, layer 11) I have a variable that if a condition exists then you add 1. that variable is r and when I list the variable after the condition exisits it lists as
_level0.instance1.instance4.dragred.r = 1

So when both conditions exists and I list variables both of these list above... Now in the frame #100 (not in the instances) I
have to add these two variables together. So this is what I wrote and the variable keeps listing as NaN so I am doing something wrong. This is my entry on frame #100, layer 10 (not on the symbol but just on the frame):

var b:Number = 0;
b = (_level0.instance1.instance4.dragred.r + _level0.instance1.instance4.dragred.y)
trace(b);

b lists it as the NaN verses 2

Help With Adding Two Variables
I need to add two variables together. This is what I did:

in a mc that I dragged to the stage (frame 100, layer 10 ) I have a variable that if a condition exists then you add 1.. that variable is y and when I list the variable (after the condition exisits) it lists as _level0.instance1.instance4.dragyellow.y = 1

On the next layer I dragged to the stage ( frame 100, layer 11) I have a variable that if a condition exists then you add 1. that variable is r and when I list the variable after the condition exisits it lists as
_level0.instance1.instance4.dragred.r = 1

So when both conditions exists and I list variables both of these list above... Now in the frame #100 (not in the instances) I
have to add these two variables together. So this is what I wrote and the variable keeps listing as NaN so I am doing something wrong. This is my entry on frame #100, layer 10 (not on the symbol but just on the frame):

var b:Number = 0;
b = (_level0.instance1.instance4.dragred.r + _level0.instance1.instance4.dragred.y)
trace(b);

Adding Variables
I'm sure this is a very simple question. I want to know how to add the values of two variables together. Right now it is literally adding them together ( 50 + 50 = 5050). My code is:

Code:
cash = wager + wager + cash;
Also, is how would I say double the wager instead of wager +wager. Is it wager(2)? Thanks a lot.

Adding Variables
hi,

failry simple answer to this one i thinks so i post on newbies...

iv fed a list of numbers through to a list of dynamic textboxes from a database. i have given the textboxes variable names - variable1, variable2 etc.

when i press a button, i want the corresponding variable to be added to another variable.

ive tried on(press) {var allnumbers =+ variable1}

but htat just replaces allnumbers with variable1. so how do I add them on?

[F8] Adding Variables Through XML
I totally suck at XML.

I got an absolutely great example of what I am trying to do, because it comes with Flash 8. If you're running windows, it's located at

C:Program FilesMacromediaFlash 8Samples and TutorialsSamplesActionScriptGalleriesgallery_t ree.fla

Now what I would like to do is add a text box to the side which gives a description of each image. How would I go about doing that? Any help would be much appreciated.

Adding To Variables
Hello

I have a form asking for the user to input 2 separate numbers
Each number is assigned to a different variable.

When I click the button to add the two numbers
1 + 1 = 11 7+7=77

When I do something like:
var a:Number = 2
var b:Numer = 4
I can get a + b to = 6

But when the numbers are coming from a form I would get 24

This is driving me crazy.....

How do I make 1 + 1 = 2

Thank You

[F8] Adding Variables Together
how do i add variables together?

when i add:

var dayfld:Number=10;
var monthfld:Number=10;

like so:

trace(dayfld+monthfld);

i get in the output box 1010

why is this?

whats the correct way to add variables?

i know its a n00b and simple question but its driving me nuts!

thanks

TedTLogan

Adding Three Variables Together
i have three variables that i need to add together and when i try (num=num1+num2+num3 it does not add them. lets say all the variables are 1 the output should be 3 but it ends up being 111.

Thanks

[f8] Adding Variables
Hi, OK, I've got 6 "score" fields, each named differently, then I've got a "sum" field where I want to add the scores of all the other 6 "scores" and display them in the "sum" field.

The score fields work, they are named:

goalBeerOne
goalBeerTwo
goalBeerThree
goalBeerFour
goalBeerFive
goalBeerSix

The sum field is called:

goalBeerSum

I tried this:


Code:
onClipEvent (enterFrame) {
_root.goalBeerSum=(_root.goalBeerOne+_root.goalBeerTwo+_root.goalBeerThree+_root.goalBeerFour+_root.goalBeerFive+_root.goalBeerSix);
}



And it did not work (returned "20100" at one point)

But it's basically what I want to do.

The variables are all initialized to "0" in a previous frame.

Anyone know how I can do this?

[F8] Help Adding Variables
Hello, I have a problem when I try to add the sums of 2 variables.

Firstly I asigned 3 variables:


PHP Code:



var initialdamage:Number = 0;
Var dealtdamage:Number = 0;
var damage:Number = 0;




I then tried to make it so that the sum of variable "initialdamage" and "dealtdamage" would become the value of "damage".

I then added this code:


PHP Code:



_root.damage = _root.initialdamage + _root.dealtdamage;




I then increased the value of "initialdamage" by 1, but the variable "damage" stayed at 0. Any ideas?

Adding Together The Value Of 2 Variables
Ok so im trying to add these two variables together...but instead of adding the value to calculate correctanswer.txt i get the 2 values side by side, ie
4 + 1 becomes 41. I guess using the + sign is where im going wrong, whats the correct equation?


Code:
question.text = random (100);
question2.text = random (10);
correctanswer.text = question.text + question2.text;
Many thanks!!

Adding Variables
Hi, I know what I should do and have read what should work - but someone help!

I have this code and it is called by a function, and is then meant to output to the textfield totalIn (simple !) and I know that the input boxes are strings and you need to convert them to numbers so why does it keep saying that the totalIn is NAN?



Code:
var totalIn:Number=0;
var in_1:Number=0
var in_2:Number=0;


function calculateIn(){
totalIn=Number(in_1)+ Number(in_2)
}
I have attached the file

thanks

Adding Variables
A simple question:

I have on my first frame


Code:
var hp:Number = 100 + _root.strengthVal;
You're allowed to "edit" strengthVal to your likings, and that's why it can't be a set number.

And on the second frame a text box with the VAR name of "hp" just like indicated in the first frame. All it says is "NaN" and I'm really lost. I've tried switching around action script, deleting some, adding some, but all hope is lost. Any suggestions?

Adding Variables Together
Hi All,

Is is possible to add two variables together? I've been trying to use eval and [] but with absolutely no joy.

Any help very much appreciated.

Cheers,

Jonny

Copyright © 2005-08 www.BigResource.com, All rights reserved