just make the parameter optional
protected function code(event:MouseEvent = null):void
Ah, but then Adobe Air throws this error at me:
Cannot access a property or method of a null object reference.
so you use event in the function
so pass the event on when you call it
or cant you just use the code function as the event handler
The event thing worked
Is it possible to have the function that cotains a lot of the code in another file, and then reference to it when i want it called?
absolutely. you just need to make a new actionscript class and have the code as method.
its what OOP is all about
My code includes addElement(), where an object is added to an MXML BorderContainer which is a separate component and i get the error that addElement is a possibly undefined ....etc