0

I want to pass a parameter to the timer's timerEvent function.

Is it possible?

I know that in c++,I can use the function object,or just use the boost::bind. Is there something like boost::bind?

wtm
  • 1,389
  • 4
  • 13
  • 18
  • 1
    [Here's](http://stackoverflow.com/questions/6406957/how-to-pass-arguments-into-event-listener-function-in-flex-actionscript) the answer – Art May 22 '12 at 10:58

1 Answers1

2

you can also extend Timer class with your custom class, for example:

public class DataTimer extends Timer 
    {
        private var _data:Object;

        public function DataTimer(delay:Number, repeatCount:int=0) 
        {
            super(delay, repeatCount);
            _data = {};
        }

        public function get data():Object 
        {
            return _data;
        }

        public function set data(value:Object):void 
        {
            _data = value;
        }
    }

and use it in your callback function

var timerObj:DataTimer = event.currentTarget as DataTimer;
trace("data: "+timerObj.data);
Antonos
  • 573
  • 2
  • 10