# Variables on two different frames

**URL:** <https://forum.kirupa.com/t/variables-on-two-different-frames/218261>\
**Category:** flash\
**Created:** [March 6, 2007, 6:14am UTC](https://forum.kirupa.com/t/variables-on-two-different-frames/218261 "2007-03-06T06:14:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eibach](https://avatars.discourse-cdn.com/v4/letter/e/edb3f5/32.png) [@Eibach](https://forum.kirupa.com/u/Eibach)\
**Post date:** [March 6, 2007, 6:14am UTC](https://forum.kirupa.com/t/variables-on-two-different-frames/218261/1 "2007-03-06T06:14:31Z")

</div>

here is my script  
Frame 1: Making the Function

[AS]stop();  
function button\_mc(target\_mc, output\_name, output\_frame, outcome\_number){  
var outcome\_num:Number = outcome\_number;  
target\_mc.mc\_txt.text = output\_name  
target\_mc.onRollOut = out;  
target\_mc.onRollOver = over;  
target\_mc.onRelease = function(){  
gotoAndStop(output\_frame);  
//trace(outcome\_num);  
}  
}  
function over() {  
this.gotoAndPlay(‘over’);  
}  
function out() {  
this.gotoAndPlay(‘out’)  
}  
button\_mc(play\_mc, “Play”, 2);[/AS]  
Frame 2: This is where i set the variable in the function  
[AS]if(name\_input == null){  
name\_output.text = “Player”  
}else{  
name\_output = name\_input  
}  
button\_mc(rock\_mc, “Rock”, 3, 1);  
button\_mc(paper\_mc, “Paper”, 3, 2);  
button\_mc(scissors\_mc, “Scissors”, 3, 3);  
button\_mc(start\_over, “Start Over”, 1);[/AS]  
Frame 3: This is where i try to trace the variable  
[AS]trace(outcome\_num);  
if(outcome\_num == 1){  
outcome\_mc.mc\_txt.text = " Wins!"

}else if(outcome\_num == 2){

}else if(outcome\_num == 3){

}[/AS]  
when i trace the variable it just says undefined, but when i trace the variable on frame two it traces the number. how do i get it to trace the number on the third frame??  
Also i was wondering i have an input text box in frame 1, and an dynamic text box on frame 2, and when i input the text it shows up in the output box, but when i try to do the if statment on frame two, make it say just “Player” when nothing is entered, it always just shows nothing, how am i supos to make it show Player?
