Quick Tip: AS3 Function parameters…..

In old AS1 / AS2 you could get away with not passing all the parameters to a function, AS3 on the other hand has none of it.

But what you can do is asssign default values for each parameter so you don’t need to pass a value it.

i.e.

function hideObject(child:DisplayObject,fadeOut:Boolean=false):void
{
   if(fadeOut)
   {
      //fadeout Tweener code
   } else {
      child.visible = false;
   };
}

hideObject(target);//would instantly hide target
hideObject(target , true);//would override default value and so fade

Aden Forshaw

Aden Forshaw is Creative Director and Chief Technical Officer over at Coull.com

Leave a Reply

Your email address will not be published. Required fields are marked *