0

Is there a way to dispatch a SWFAdresss CHANGE Event but also pass parameters (an Object) along with it?

I see something like that in the documentation but I can't find an example online...

redconservatory
  • 21,438
  • 40
  • 120
  • 189

1 Answers1

0

You could modify the SWFAddressEvent class like so:

 private var _customObject:Object;

public function SWFAddressEvent(type:String, customObject:Object, bubbles:Boolean = false,  cancelable:Boolean = false) {
        super(type, bubbles, cancelable);

        _customObject = customObject;
    }

and then when you dispatch the CHANGE event, add the object to the Event:

dispatchEvent(SWFAddressEvent.CHANGE, customObject);

To make the Object publically available:

public function get publicCustomObject():Object
{
    return _customObject;
}
daihovey
  • 3,485
  • 13
  • 66
  • 110
  • That sounds good...does the _customObject have to be public, then? – redconservatory Sep 20 '10 at 13:53
  • _customObject is the private variable we've assigned to the variable passed with the event. If you want the Object to be viewable by other Classes then, for good OOP, I would create a seperate public variable and add a setter, setting the new public variable with _customObject. – daihovey Sep 20 '10 at 23:33