Вы хотите создать пользовательское событие:
package
{
import flash.events.Event;
public class CounterEvent extends Event
{
public static const VALUE_CHANGED:String = 'valueChanged';
public var before:int;
public var after:int;
public function CounterEvent(type:String, before:int, after:int)
{
this.after = after;
this.before = before;
//bubbles and cancellable set to false by default
//this is just my preference
super(type, false, false);
}
override public function clone() : Event
{
return new CounterEvent(this.type, this.before, this.after);
}
}
}
Это изменит ваш код на:
package com.my.functions
{
import CounterEvent;
import flash.events.EventDispatcher;
public class counterWithListener extends EventDispatcher
{
private var _counter:Number = 0;
public function counterWithListener() { }
public function set counter(value:Number):void
{
this.dispatchEvent(new CounterEvent(CounterEvent.VALUE_CHANGED, _counter, value));
_counter = value;
}
}
}