How can you write the line below programmatically?
<local:Item mouseMove="mouseMoveHandler(event)" prop1="value1" prop2="value2" />
Here’s the solution:
var item1:Item = new Item();
item1.prop1 = "value1";
item1.prop2 = "value2";
item1.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
Assuming that you have the following function:
public function mouseMoveHandler(event:MouseEvent) {
(. . .)
}
If you need to access to an attribute of the Item object inside the mouseMoveHandler function, then you can use the following:
var item:Item = event.target;
event.target will return the corresponding Item object.