PDA

View Full Version : Difference in functions.


FEK315
03-04-2011, 04:12 PM
Why some functions written:

function onRotateRight(evt:MouseEvent):void{
box.rotation += 20;
}

and some are written with out the (evt:MouseEvent):void
Like this:
public function EventPropogation2() {
folder_group.addEventListener(MouseEvent.MOUSE_OVE R, onFolderOver);
folder_group.addEventListener(MouseEvent.MOUSE_OUT , onFolderOut);
}

Thank you

Didi_
03-04-2011, 06:02 PM
When you put stuff in a function parenthesis, you are giving it a parameter.

That means this function will only be dispatched after receiving what is asked in the parenthesis. Just like: the first function, 'onRotateRight', can only be called after its given a MouseEvent.

The second one, 'EventPropogation2()', since it does not have any stuff in parenthesis, it does not require any parameters, therefore it can be called any time of the script, without giving any errors.

Hope I helped!

FEK315
03-04-2011, 10:29 PM
Yes this helps a lot
Thank you