View Full Version : Pass MouseEvent as Parameter
Niche
10-12-2008, 06:41 AM
I would like to pass a mouse event : MouseEvent.CLICK as a parameter.
example:
activateEvent(MouseEvent.Click,clickedEvent);
function activateEvent(event:MouseEvent,destination):void{
mc.addEventListener(event,destination,false,0,true );
};
Any Thoughts?
rawmantick
10-12-2008, 06:43 AM
addEventListener(event.type ...
Strange construction you have here...
Niche
10-12-2008, 07:11 AM
could you be a bit more specific please. Thank you.
rawmantick
10-12-2008, 08:16 AM
If you want to simple get a type of event you've cought - you can use event.type property.
Strangeness is in mistyping arument types. You pass MouseEvent.CLICK (which is a String) to a function, that wants to get MouseEvent instance, but not a String.
lordofduct
10-12-2008, 08:55 AM
no offense, but the method activateEvent does the same thing as addEventListener...
evtDispatcher.addEventListener( EventType, function, false, 0, true );
as opposed to your own code is the same thing.
Oh and for clarification, the event types are just strings.
MouseEvent.CLICK == "click"
Event.ENTER_FRAME == "enterFrame"
so the param should be of type String, not of type Event... the Event object is the object the dispatchers hands to the listener upon the capture of that event.
and you might want to type "destination" to function, because that's what that should be as well.
And finally as romantique said, Event.type is the type of event (the string) that had fired.
...
One thousand posts! WOOT!
rawmantick
10-12-2008, 09:08 AM
Congrats, comrad :D:)
flashDuniya
01-30-2009, 12:27 PM
I would like to pass a mouse event : MouseEvent.CLICK as a parameter.
example:
activateEvent(MouseEvent.Click,clickedEvent);
function activateEvent(event:MouseEvent,destination):void{
mc.addEventListener(event,destination,false,0,true );
};
Any Thoughts?
Here is the correct code for pass the parameters:
create a movieClip or button with the instance name mc
mc.addEventListener( MouseEvent.CLICK, getHandler('flashDuniya.com') );
function getHandler(i) {
return function(e:MouseEvent) {
trace("Welcome: ", i);// Welcome flashDuniya.com
}
}
I think it will be usefull
flashDuniya
Flash Development Team
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.