jeudi 2 mars 2017

Change variable value inside two functions and show result in another function

I'm new at programming, and I have faced a problem in my code bellow. I keep getting the same value of the created variable inside last function without taking the change of the other functions. So this is what I want to do: I want to use a value of the variable "state" from last applied function "onActivate" or "onDeactivate" and test this variable "state" inside a "ShowState" function.

import flash.utils.Timer;


var state: Boolean = true;

        stage.addEventListener(Event.ACTIVATE, onActivate);
        stage.addEventListener(Event.DEACTIVATE, onDeactivate);
  function onActivate(Event): void {
                        state == true;

        function onDeactivate(Event): void {
                        state == false;
        var StateTime: Timer = new Timer(6000, 0);
        StateTime.addEventListener(TimerEvent.TIMER, ShowState);
        function ShowState(evt: Event): void {
                if (state == true) {

Aucun commentaire:

Enregistrer un commentaire