doublemazaa
December 4th, 2008, 12:40 AM
Minor frustration...
I write a function to be called when I click on an object, but never use reference to the event I pass to the function.
object.addEventListener(MouseEvent.CLICK, blowUp);
function blowUp(thisEventIsNeverReferenced:Event):void{
//Stuff happens here
}
Then later I want to call blowUp from actionscript without passing an event, but now actionscript complains that I'm not passing an event to the function. Is there anyway around this? Can I write my event listeners so they don't pass an event or can I write my functions to optionally accept input?
I know I can do the following, also, but am looking to see if there's an easier way.
//This results in a program full of shell functions
object.addEventListener(MouseEvent.CLICK, activateBlowUp);
function activateBlowUp(thisEventIsNeverReferenced:Event):v oid{
blowUp();
}
function blowUp():void{
//Stuff happens here
}
or
//Send dummy variable through - probably a bad practice to follow an required extra dummy code
object.addEventListener(MouseEvent.CLICK, activateBlowUp);
function blowUp(thisEventIsNeverReferenced:Event):void{
//Stuff happens here
}
var foo:Event = new Event("this is a waste of my time");
blowUp(foo);
Thanks.
I write a function to be called when I click on an object, but never use reference to the event I pass to the function.
object.addEventListener(MouseEvent.CLICK, blowUp);
function blowUp(thisEventIsNeverReferenced:Event):void{
//Stuff happens here
}
Then later I want to call blowUp from actionscript without passing an event, but now actionscript complains that I'm not passing an event to the function. Is there anyway around this? Can I write my event listeners so they don't pass an event or can I write my functions to optionally accept input?
I know I can do the following, also, but am looking to see if there's an easier way.
//This results in a program full of shell functions
object.addEventListener(MouseEvent.CLICK, activateBlowUp);
function activateBlowUp(thisEventIsNeverReferenced:Event):v oid{
blowUp();
}
function blowUp():void{
//Stuff happens here
}
or
//Send dummy variable through - probably a bad practice to follow an required extra dummy code
object.addEventListener(MouseEvent.CLICK, activateBlowUp);
function blowUp(thisEventIsNeverReferenced:Event):void{
//Stuff happens here
}
var foo:Event = new Event("this is a waste of my time");
blowUp(foo);
Thanks.