Creating Your Own Objects and Behaviors in Dreamweaver
- Before Getting Started
- Working with Objects
- Working with Behaviors
- Sharing Extensions
- Summary
In the previous chapter, you learned how to take advantage of Dreamweaver extensions written by other people. Now it's time to learn to write your own! In this chapter,you'll get some hands-on experience creating custom objects andbehaviors, and you'll learn how to package them up and share them with the rest of the Dreamweaver community. In particular, you'll learn to do the following:
Create a simple object that inserts the same code into the page every time
Create a custom object that uses a dialog box to collect user input and insert customized code into the page
Create an editable, reusable custom behavior
Troubleshoot and bulletproof objects and behaviors for distribution to others
Package a behavior or object into an installation file that can be used with Extension Manager
Submit a packaged extension to the Macromedia Exchange
Before Getting Started
Although writing Dreamweaver extensions isn't just for propeller-heads, it isn't for sissies, either. To work with object and behavior files, you need to be fairly comfortable reading and writing HTML code, and you need at least a basic understanding of JavaScript. In particular, before you tackle this chapter, you should be familiar with the following:
The basic language structure, syntax requirements, and concepts of JavaScript (expressions, operators, variables, and so on)
How to work with JavaScript functions
How to use JavaScript to process data collected by HTML forms
TIP
If you're a JavaScript newbie, or if your skills are rusty, you might want to have a JavaScript reference available as you work. The handiest reference is Dreamweaver's own online JavaScript Reference panel. If you want more in-depth information, the O'Reilly series books on JavaScript (JavaScript: The Definitive Guide, JavaScript Pocket Reference) are a valuable resource. Danny Goodman's JavaScript Bible is also a wonderful reference and teaching resource.
In addition to the standard rules and regulations of JavaScript, Dreamweaver has its own application program interface (API), consisting of predefined objects, functions, and procedures for processing scripts. In the course of this chapter, you'll get a taste of the Dreamweaver API, and you'll be introduced to the parts of the API that you'll need to write basic objects and behaviors. If you want to go beyond this chapter and seriously explore Dreamweaver extensions, the best resource is Macromedia's own manual, Extending Dreamweaver. This manual comes in PDF format on the Dreamweaver application CD; it can also be downloaded from the Dreamweaver support page on the Macromedia Web site ( http://www.macromedia.com/support/dreamweaver). I highly recommend printing it out, popping it in a three-ring binder and keeping it next to your pillower, your computeras you work.
So, are you ready to start extending?