Practical prototype and part 42: The information in this book is distributed on an "as is" basis, without warranty Although every pre-caution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. | CHAPTER 10 INTRODUCTION TO EFFECTS 241 The element we told to fade out is still visible it s only just begun animating. That s because the interpreter doesn t wait around it schedules the frames of the animation and then moves on to the next line. gives us two ways around this. The first way is using effect callbacks which are very similar to the Ajax callbacks you learned about in Chapter 4. The second is using effect queues which can force effects to wait their turn behind other effects. Callbacks Both core effects and combination effects treat certain parameters passed into the options argument as callbacks beforeSetup and afterSetup are called before and after the setup stage of an effect in which the effect makes any necessary modifications to the element itself. beforeStart and afterStart are called before and after the first frame of an effect respectively. beforeUpdate and afterUpdate are called before and after each frame of an effect. beforeFinish and afterFinish are called before and after the finish stage of an effect in which the effect reverts any changes it made in the setup stage. To ensure that our alert dialog appears after the effect is complete we can use the afterFinish callback box afterFinish function effect debugger Figure 10-19 shows that the element is completely invisible before the debugger starts. 242 CHAPTER 10 INTRODUCTION TO EFFECTS Figure 10-19. By moving the debugger statement to a callback we ensure that it runs after the effect has finished. Taken together these callbacks provide hooks into every single frame of an effect. They re the ultimate override. Most of the time afterFinish will be all you need but it s nice to know the rest are there. Each callback takes the effect instance itself as the first argument. Since the class from which all effects derive defines some instance properties you re able to use these same properties in your callbacks