I understand how to declaratively assign a method to be called when an Image receives a MouseMove event.
<mx:Image id='oneCent' mouseMove='dragIt(event, 1);' />
How do I do this programmatically in Flex/AS3?
EDIT: Thanks for the comments. Here’s what I have so far:
myImage = new Image(); myImage.id = 'oneCent'; myImage.addEventListener(MouseEvent.MOUSE_MOVE, dragIt);
The code snippet above assigns the dragIt method to the MOUSE_MOVE event for myImage. So far, so good. How do I pass in the 2nd parameter to the call to dragIt?
You can’t pass the second param directly – so add it to myImage:
Then in the dragit function:
Where event.target automatically becomes a reference to the image