So I have a button that I have attached 2 EventListeners to. It is listening for a MOUSE_OVER and a MOUSE_OUT.
ECM_button.addEventListener(MouseEvent.MOUSE_OVER, RollOverECM);
ECM_button.addEventListener(MouseEvent.MOUSE_OUT, RollOverECM);
As you can see, both events call the same function. In this function, I would like to create a new instance of a library object and then hide it, depending on the mouseEvent that fires:
var ECMBox:MovieClip = new managerBox();
addChild(ECMBox);
On the MouseOUT, I would then like to remove that from the stage as such:
removeChild(ECMBox);
I did it this way instead of firing two seperate functions because the second function has no reference to the object created in the MOUSE_OVER function and therefore cannot remove it.
My question is this: Is there a way to determine in the function that is called, what mouse event called it? If I could get that, then I could set up a condition to create and object or hide the object, depending on what event was fired. Something like this:
ECM_button.addEventListener(MouseEvent.MOUSE_OVER, RollOverECM);
ECM_button.addEventListener(MouseEvent.MOUSE_OUT, RollOverECM);
function RollOverECM(event:MouseEvent):void {
if (MOUSE_OVER)//unknown code here
var ECMBox:MovieClip = new managerBox();
addChild(ECMBox);
// Do stuff here, populate the object with data, etc...
else(MOUSE_OUT)//More unknown code
removeChild(ECMBox);
There is a very good chance I am going about this completely wrong and there is a much easier way. Please advise.