lingoadobe-director

Adobe Director - Lingo Quiz


So I have a quiz I'm making using Adobe director, but I'm struggling with the overall environment.

I'm adding the following Lingo script to each button with a correct answer:

  on mouseDown
    global gscore
    set gscore = gscore + 1

And on the final stage, I use the following Lingo script to check the acquired points, and display the appropriate sprite for the result.

on enterFrame
  if gscore = 0 then set the memberNum of sprite (3) to 154
end if
  if gscore = 1 then set the memberNum of sprite (3) to 155
end if
  if gscore = 2 then set the memberNum of sprite (3) to 156
end if
  if gscore = 3 then set the memberNum of sprite (3) to 157
end if
  if gscore = 4 then set the memberNum of sprite (3) to 158
end if
  if gscore = 5 then set the memberNum of sprite (3) to 159
end if
end

So my errors seem to say there is no declared variable, but it's global right? So how come it doesn't recognise it. The first script is attached to the buttons corresponding to correct answers, each button has a seperate script to send it to the next question. The final stage which is meant to display the results should display a certain custom sprite dependant on the value of gscore.


Solution

  • Figured it out, appologies.

    I removed all the end if's to make it a complete if statement. Set the global variable on the first script used declaring the value as 0. Then later when incrementing it is adding to a previously defined global variable of the same name.

    I believe my problem lay in global variable instances default value being void.