Publishers of technology books, eBooks, and videos for creative people

Home > Articles

  • Print
  • + Share This
From the author of

Running Conditional Code with OnClipEvent

A clip event enables you to add a unique block of code to an instance of a movie clip. You can also define the conditions under which the code will be run. The command syntax is made up of two sections. The keyword, contained within parenthesis, defines when the code or 'statement block' within the curly brackets will be run.

Look at the text file in your editor. You'll notice that it currently contains two empty clip events. Any code you add within the body (the area between the curly brackets) of the onClipEvent (load) section is run when the movie clip first appears. This is where you will put your function definitions and any initialization code.

Code placed within the body of the onClipEvent (enterFrame) section, however, will be run on the second frame and every subsequent frame thereafter. Although loads of conditions for clip events exist, these two are the most common.

  • + Share This
  • 🔖 Save To Your Account