5 Replies Latest reply on Oct 16, 2006 7:08 AM by jonnybennett


    jonnybennett Level 1
      I'm having problems understanding listeners... I think I get the basic idea. An object is created to listen for an event, that when occurs will perform a function. However it is the event bit I am having a problem with. certain events work for certain things. eg...
      .change works if a component is changed, however it doesn't work for a variable. Why does the folowing code not work, when the value of _global.nData is changed?

      var oListener:Object= new Object();
      oListener.change = function(oEvent:Object):Void {

      thanks J.
        • 1. Re: listeners
          Glazer Level 1
          i'm no expert on the use of listeners, but there's a simpler solution for the example you've posted:

          nData.onChanged = function():Void {
          • 2. Re: listeners
            jonnybennett Level 1
            thanks, Glazer, that be my answer, You wouldn't need a listener.
            • 3. Re: listeners
              jonnybennett Level 1
              However, having said that that is the answer I can't seem to get it to work. When the value of _global.nDepth is changed, should the nTotal.text not change with it??

              _global.nDepth.onChanged=function():Void {
              • 4. listeners
                Glazer Level 1
                I think you misunderstand the usage of the "_global" keyword... um...
                you use this declaration when you want to have access to a specific variable anywhere in your flash file, but you only need to declare it once. That being said, if your flash file is fairly simple, and if you're using AS2 then the "_global" declaration shouldn't be necessary.

                BTW: "nData" is a TextField? and "nTotal"?

                Hope this helps
                • 5. Re: listeners
                  jonnybennett Level 1
                  _global. That is causing the problem.
                  Inact it is probably my bad knowledge of actionscript, that is the problem. Although I think I am doing ok as I am self taught. Anyway thanks Glazer. Problem solved.