Copy link to clipboard
Copied
So I am just doing a basic form. Frame one has flash components like radio buttons, text input, yada yada ya, frame 02 just has a summary. Everything works perfectly, except for my variables which store the first name and last name that is enterered into the text input fields and I don't know why its not working. I have tried numerous different methods and nothing seems to work. I am guessing it has something to do with the variable scope, but there is nothing I have done to make it local. In fact, I have initiated those variables alongisde another, and within the same function I assign a value to one variable and it works, and when I assign values to the first and last name variables, it will not transfer over to 2nd frame, even though its written in the exact same manner as another that works. Here is frame 01:
var year:String = "";
radio_00.addEventListener(MouseEvent.CLICK, radio)
radio_01.addEventListener(MouseEvent.CLICK, radio)
radio_02.addEventListener(MouseEvent.CLICK, radio)
radio_03.addEventListener(MouseEvent.CLICK, radio)
function radio(e) {
if (radio_00.selected) {
year = "0";
}
if (radio_01.selected) {
year = "1-2";
}
if (radio_02.selected) {
year = "3-4";
}
if (radio_03.selected) {
year = "5+";
}
}
var living:String="";
var firstN:String="";
var lastN:String="";
done_btn.addEventListener(MouseEvent.MOUSE_UP, done)
function done(event:MouseEvent) {
if (live_box.selected) {
living = "do";
} else {
living = "do not";
}
var lastN = last_txt.text;
var firstN = first_txt.text;
trace(living);
trace(firstN);
trace(lastN);
gotoAndPlay("end");
}
stop();
and now frame 02:
stop();
textArea_txt.text =
"My name is " +firstN+ " " +lastN+ ".\nI have " +year+ " years of post-seconday experience.\nI " +living+ " live in Saskatchewan.";
***THE VARIABLES firstN and lastN HAVE A BLANK VALUE HERE, NOT NULL, JUST BLANK. I HAVE NO IDEA WHY, FOR IF YOU LOOK AT HOW THE VARIABLE living IS DECLARED AND ASSIGNED A VALUE, ITS ALMOST THE SAME. ANY HELP WILL BE MUCH APPRECIATED
You are decalring entirely new variables inside the function and their scope is limited to within the function. You should only be assigning the values to the ones you declare outside. The ones outside will have global scope so long as the layer that the code is in extends the full length of the timeline... inside the function should only be...
lastN = last_txt.text;
firstN = first_txt.text;
Copy link to clipboard
Copied
You are decalring entirely new variables inside the function and their scope is limited to within the function. You should only be assigning the values to the ones you declare outside. The ones outside will have global scope so long as the layer that the code is in extends the full length of the timeline... inside the function should only be...
lastN = last_txt.text;
firstN = first_txt.text;
Copy link to clipboard
Copied
Ned my man, you are a genius! Thank you!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now