If you pass a null value to an optional parameter, the function uses the default values defined in the declaration.
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Script><![CDATA[ import mx.controls.Alert; import mx.core.Application; public var app:* = null; /** */ private function doTest():void { funcTest(null,null,"bar"); }// private function funcTest(param1:int=0, param2:int=1,param3:String='foo'):void { Alert.show("param1=" + param1 + " param2=" + param2 + " param3=" + param3) }//funcTest ]]></mx:Script> <mx:Button label="test" click="doTest()" /> </mx:Application> Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Amy Sent: Friday, November 14, 2008 5:02 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Calling functions with optional parameters --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > What if you explicitly passed null? > > theFunction(null,null,'bar'); The defaults aren't always null, and MPO is that the developer shouldn't need to know what the appropriate default is to make the default behavior. I feel like I'm really sure that I've seen places in the framework code where functions are called this way, but I'm not sure how to search in there to get verification. It would be really, really nice if the docs were detailed enough that I could get a good sense of whether I'm barking up the wrong tree (of course the docs are wrong or misleading a good percentage of the time, so detail is no guarantee) ;-). Thanks; Amy