Quick Tip

Problem with Flash Player 9.0.28 or below?

Tuesday, May 5th, 2009 | Actionscript 3, Quick Tip | No Comments

Try adding this little line in your document class constructor to create the ADDED_TO_STAGE constant as this was not present in players 9.0.28 or below.

Bit of a hair puller this one.

if (Event.ADDED_TO_STAGE == null)
{
Event["ADDED_TO_STAGE"] = “addedToStage”;
}

Tags:

Quick Tip: AS3 Function parameters…..

Tuesday, September 2nd, 2008 | Actionscript 3, Quick Tip | No Comments

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

Tags: ,

Search