var myAnim = new YAHOO.util.Anim ("dlg"); myAnim.attributes.opacity = { from: 0, to: 1 }; myAnim.duration = 2; myAnim.method = YAHOO.util.Easing. easeIn; myAnim.onComplete.subscribe (showDialog);
In Script 16.14, we create a new animation object
myAnim , based on
dlg , the dialog object from the previous task. We give it an opacity that will start at zero and end at one (bringing it from invisible to visible), we set the animation's duration to be two seconds, and we set its method to
Easing.easeIn (a built-in style that tells JavaScript to start off fast but then
ease in to displaying the object). Finally, we tell the animation that when it's done (that is, when its
onComplete event handler is triggered), it should call the
showDialog() function, as it's
subscribed that is, a function has been signed up to do something after a
myAnim event has taken place.