View Full Version : MC's and passing vars to main timeline
deveau31
11-07-2005, 03:16 PM
Ok, I think I am doing something stupid. Here's the story. I have a movie that is 4 frames long. On the first frame there are input boxes and when values are entered and the submit button is clicked, they get passed to the 2nd frame and things happen...works great...until...
I wanted to allow the user to print each frame separately, so I added a print button to each frame and labeled each frame with #p. So, in order to print ONLY the first frame from the print button on that frame, I was forced to put everything on frame 1 into an MC. Now that I've done so, none of the vars are passing to the second frame.
I went into the code on the second frame and added _root.frame1.blah so it knows where to get it, but still nothing.
Like I said, I am probably just doing something stupid, but can't figure out what. So there are probably a few answers to this question. I could either figure out how to "target" the vars, or figure out a better way to print. Which is easiest? Thank you in advance.
sophistikat
11-07-2005, 03:29 PM
have you tried _parent?
deveau31
11-07-2005, 03:46 PM
yes, I have. When I converted the input boxes and submit button into the MC, none of the variables passed anymore, so I'm assuming it's a targetting issue, but I can't figure it out.
Let me give you an example:
Here's the code I had before I turned everything into an MC on the first frame:
on (release) {
if (nogo == true) {
nogo == false;
} else {
//quick fix
a = Number(saved.text);
b = Number(onepos.text);
c = Number(twopos.text);
d = _root.checker(Number(id));
e = _root.checker(Number(ie));
pb = parseFloat(prepby.text);
pf = parseFloat(prepfor.text);
/*
if (d >= 0) {
d * -1;
} else {
break;
}
if (e >= 0) {
e * -1;
} else {
break;
}
*/
newonepos = b/100;
newtwopos = c/100;
newthreeneg = d/100;
newfourneg = e/100;
h = a*(1+newonepos)*(1+newtwopos);
secbal = h;
i = a*(1+newonepos)*(1+newtwopos)*(1+newthreeneg)*(1+n ewfourneg);
fourbal = i;
j = a*(1+newonepos);
onebal = j;
k = a*(1+newonepos)*(1+newtwopos)*(1+newthreeneg);
threebal = k;
recovery = h-i;
f = (recovery/fourbal)*100;
recoveryper = f;
l = recovery/fourbal;
g = 1+l;
onerec = Math.pow(g, 1/1)-1;
tworec = Math.pow(g, 1/2)-1;
threerec = Math.pow(g, 1/3)-1;
fourrec = Math.pow(g, 1/4)-1;
fiverec = Math.pow(g, 1/5)-1;
_parent.gotoAndStop(2);
}
}
And then here's the code after I turned everything on the first frame into an MC:
on (release) {
if (nogo == true) {
nogo == false;
} else {
//quick fix
a = Number(_parent.saved.text);
b = Number(_parent.onepos.text);
c = Number(_parent.twopos.text);
d = _root.checker(Number(_parent.id));
e = _root.checker(Number(_parent.ie));
pb = parseFloat(_parent.prepby.text);
pf = parseFloat(_parent.prepfor.text);
/*
if (d >= 0) {
d * -1;
} else {
break;
}
if (e >= 0) {
e * -1;
} else {
break;
}
*/
newonepos = b/100;
newtwopos = c/100;
newthreeneg = d/100;
newfourneg = e/100;
h = a*(1+newonepos)*(1+newtwopos);
secbal = h;
i = a*(1+newonepos)*(1+newtwopos)*(1+newthreeneg)*(1+n ewfourneg);
fourbal = i;
j = a*(1+newonepos);
onebal = j;
k = a*(1+newonepos)*(1+newtwopos)*(1+newthreeneg);
threebal = k;
recovery = h-i;
f = (recovery/fourbal)*100;
recoveryper = f;
l = recovery/fourbal;
g = 1+l;
onerec = Math.pow(g, 1/1)-1;
tworec = Math.pow(g, 1/2)-1;
threerec = Math.pow(g, 1/3)-1;
fourrec = Math.pow(g, 1/4)-1;
fiverec = Math.pow(g, 1/5)-1;
_parent.gotoAndStop(2);
}
}
However, on the second frame, none of the values are getting pulled in. Here's what I had on the second frame before:
newsecbal=this._parent._parent.makeCurrency(this._ parent._parent.secbal);
newfourbal=this._parent._parent.makeCurrency(this. _parent._parent.fourbal);
newonebal=this._parent._parent.makeCurrency(this._ parent._parent.onebal);
newthreebal=this._parent._parent.makeCurrency(this ._parent._parent.threebal);
newrecovery=this._parent._parent.makeCurrency(this ._parent._parent.recovery);
newrecoveryper=Math.round(this._parent._parent.rec overyper);
And here's what it looks like after I turned the first frame into an MC(frame1 is the instance name of the new MC created on the first frame):
newsecbal=this._parent._parent.makeCurrency(this._ parent._parent.frame1.secbal);
newfourbal=this._parent._parent.makeCurrency(this. _parent._parent.frame1.fourbal);
newonebal=this._parent._parent.makeCurrency(this._ parent._parent.frame1.onebal);
newthreebal=this._parent._parent.makeCurrency(this ._parent._parent.frame1.threebal);
newrecovery=this._parent._parent.makeCurrency(this ._parent._parent.frame1.recovery);
newrecoveryper=Math.round(this._parent._parent.rec overyper);
sophistikat
11-07-2005, 04:08 PM
can you post your fla
deveau31
11-15-2005, 04:07 PM
Hi everyone,
I still haven't solved this issue and the client is looking for the file.
Does anyone have an idea how I could do this? I'm sure it's something easy.
Again, I basically have an MC on frame one that has 5 input boxes with variable names and then there's a submit button that runs the calculations. When the submit button is clicked, I want it to go to frame 2 which displays the dynamic text from frame 1. I had this working fine until I wrapped frame 1 into an MC, so that means it's a scoping issue, but everything I tried doesn't work.
Thanks in advance.
sophistikat
11-16-2005, 04:14 PM
i guess you can't post your fla?!
what i do to pass variables from movieclips to movieclips to frame in movieclips etc. etc and what i was taught is to have all your variables reside in your root so that when you ask for a value all you need is _root.myVar instead of _root.myMc.myOtherMc.myVar
if you give your dynamic textfields an instance name on frame 2, your AS should look something like this:
txtField1.text = _root.myVar1
txtField2.text = _root.myVar2
txtField3.text = _root.myVar3
txtField4.text = _root.myVar4
this also works
fou99004
11-16-2005, 04:21 PM
Another quick question: What is the instance name of your movie clip. Usually when I need something to from my mc I neeed to reference it by its instance name. Ex:
textField.text = _root.(mc instance name).(what ever I want from my mc) I didn't see anything in your code that looked like a reference to the mc's instance name so that is why I bring this up. Hope it helped.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.