How to set global variable?
I have following UI:

When I press A button or B button, output result will be: value += 1, I don't know how to store global variable, you can show me a link or some keywords to resolve problem ...?! Thanks for reading!
I have following UI:

When I press A button or B button, output result will be: value += 1, I don't know how to store global variable, you can show me a link or some keywords to resolve problem ...?! Thanks for reading!
Hi.
When you say "global" I understand you want a variable that is available for all these UI elements, right?
If so, you can write something like this:
HTML5 Canvas:
var result = 0;
function setResult(e)
{
this.outputText.text = String(++result);
}
this.buttonA.on("click", setResult, this);
this.buttonB.on("click", setResult, this);
AS3:
import flash.events.MouseEvent;
var result:uint = 0;
function setResult(e:MouseEvent):void
{
outputText.text = String(++result);
}
buttonA.addEventListener(MouseEvent.CLICK, setResult);
buttonB.addEventListener(MouseEvent.CLICK, setResult);
I hope this helps.
Regards,
JC
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.