Why won't Variable A equal Variable B
Hello all
I have a page in my Flash file where a user can select one of three values, and it will add or subtract from the variable I have on Frame 1.
So on Frame 1 I say:
var f2f:Number = 5;
var coach:Number = 5;
var mentor:Number = 5;
And on Frame 13 I was saying:
btnP13toP14.addEventListener(MouseEvent.CLICK, NavPage14);
btnContentSmall.addEventListener(MouseEvent.CLICK, contentSmall);
btnContentLarge.addEventListener(MouseEvent.CLICK, contentLarge);
function contentSmall(event:MouseEvent):void
{
f2f = -10
coach = -10
mentor = -10
}
function contentLarge(event:MouseEvent):void
{
f2f = +10
coach = +10
mentor = +10
}
But it occurred to me that if the user clicks on btnContentSmall, and then on btnContentLarge, the values would become 5, rather than 10.
So now what I am trying to do is add temporary variables to Frame 13 that store the correct value, and then update the original values when I go to the next frame (which will have a similar process).
Here is what I have now on Frame 13:
btnP13toP14.addEventListener(MouseEvent.CLICK, NavPage14);
btnP13toP14.addEventListener(MouseEvent.CLICK, copyBack);
btnContentSmall.addEventListener(MouseEvent.CLICK, contentSmall);
btnContentLarge.addEventListener(MouseEvent.CLICK, contentLarge);
var f2fTemp:Number = f2f;
var coachTemp:Number = coach;
var mentorTemp:Number = mentor;
function contentSmall(event:MouseEvent):void
{
f2fTemp = f2f-10
coachTemp = coach-10
mentorTemp = mentor-10
}
function contentLarge(event:MouseEvent):void
{
f2fTemp = f2f+10
coachTemp = coach+10
mentorTemp = mentor+10
}
function copyBack(event:MouseEvent):void
{
f2f = f2fTemp;
coach = coachTemp;
mentor = mentorTemp;
trace ("I ran the CopyBack script");
}
The Trace statement on the last function is displayed, but when I trace the variables on Slide 14, the f2f, coach and mentor variables have not updated: they are still all 5.
Does anyone have any idea what I'm doing wrong? I found one website that said I might need to use a class; but I didn't really understand how to translate that information into a solution.
Thank you
M Hetherington
