Hey folks, need some of your expert help.
Im creating an online survery and recording all the answers as a variable in _root.vars.variablename where each question creates a new variable in the vars clip.
When the user answers a question the variable is created and given a value e.g.
_root.vars.variablename1 = 1
_root.vars.variablename2 = 1
_root.vars.variablename2 = 0
But I need a piece of code to check if the variable has actually been created. The reason for this is I have a next button the user has to click once they have answered, and I dont want them to advance if they havent answered. So I need to add something like if (_root.vars.variablename1 exists ) {gotoAndPlay(“answered”);} else{ gotoAndPlay(“noAnswer”);}
Obviously the code above is wrong, I just need something to replace the ‘exists’.
Any help appreciated!!
No worries folks, got it sorted!
if (_root.vars.gender !== undefined) {
Why don’t you just set the questions up as an array and have the array elements store ‘false’ if the question hasn’t been answered and ‘true’ if it has. That way you don’t need to keep declaring variables for each new question.
[quote=randomagain;2330006]???
I am sure[/quote]
Ooops, fixed that!
And we cant store questions as true / false as some are multiple choice, multiple select and text entry.
!= and !== are essentially the same thing. != a.k.a. the inequality operator, when being used, converts data types (to strings) to check for inequality; thus 2 != “2” will return false whereas !== a.k.a. the strict inquality operator does take data types into account; thus 2 !== “2” will return true as both of the values aren’t number
Ok store questions as 1/2/3/4/5 and 0
0 being unanswered and 1/2/3/4/5 being the choice. Just saves having to declare vars