|
SYS-CON.TV Webcasts
Comments
Did you read today's front page stories & breaking news?
SYS-CON.TV
|
Top Links You Must Click On
Dreamweaver Still Snowing
Upgrading your snowman
By: Jim Babbage
Jan. 21, 2005 12:00 AM
In "Let It Snow, Man" (MXDJ Vol. 2, issue 12), I used Fireworks to create all the essential ingredients for our frozen friend. We then exported the pieces using Export as CSS Layers. This gave us a starting HTML page (generated by Fireworks) and all of our graphics in absolutely positioned DW layers (DIVs). In this article we will work in Dreamweaver and use the Drag Layer behavior to create a Web page where you can move all the snowman pieces together and build your own snowman online. The Drag Layer behavior uses Dynamic HTML (DHTML) to make your page interactive. This concept could be applied to many different uses: visual quizzing, jigsaw puzzles, and other holidays, just to name a few. Layers Can Be Such a Drag . . . or Not You need to locate the Drag Layer JavaScript file ({dw install folder}/Configuration/Behaviors/Actions/Drag Layer.js). On my Windows XP Pro system, this is found in: C:/Program Files/Macromedia/Dreamweaver MX 2004/Configuration/Behaviors/Actions/Drag Layer.js. If you're not on Windows XP Pro, Danilo has also kindly blogged the Dreamweaver Configuration files locations. 1. In Drag layer.js go to line 161 and change it from: else if (NS6){style.left = newLeft; style.top = newTop;} to: else if (NS6){style.left = newLeft+'px'; style.top = newTop+'px';} 2. Then go down to line 174 and change it from: else if (NS6) {style.left = MM_targL; style.top = MM_targT;} to: else if (NS6) {style.left = MM_targL+'px'; style.top = MM_targT+'px';} The first change allows the specified layer to be dragged, and the second change allows the layer to snap to a location when dropped if that option is selected within the Drag Layer behavior dialog. Notice that in both cases all we added was the unit of measure (px) to the values being assigned. 3. Close and restart Dreamweaver and it should happily add in the correct code to run in valid pages for Mozilla. With that little task out of the way, let's do a little under-the-hood work on the HTML page created by Fireworks. Please note that even with these changes, the Drag Layer behavior does not function in the Safari browser. Turning a Fireworks HTML Page into an XHTML-Compliant Page Note: Due to a bug in Internet Explorer 6 the name attribute causes the layers not to be draggable, even though they are in some other browsers. By replacing the name attribute with the alt attribute, you eliminate this problem and make your page more accessible. Before we go any further we will do a Find and Replace for this attribute, and change it from name to alt. XHTML compliancy requires that all images have an alt attribute, even if it is left blank. If you wish, you can edit the alt attributes later, giving each graphic a better description. However, for the purposes of this page which is really a visual experience I think the basic alt text will suffice. 1. In Dreamweaver, go to Edit>Find and Replace. Use these settings.
2. Choose Replace All and DW will cycle through your HTML code, making the changes for you. This is a whole lot easier than searching on your own! 3. With basic alt tags set, let's now convert this page to an XHTML-compliant page. Dreamweaver makes this step quite easy too. 4. Switch to Code View for a moment to see what happens when you do the next couple of steps. Look at the beginning of the code. It should resemble what you see in Listing 1, line spaces and all. 5. Notice that there is no doctype. Go to File > Convert > XHTML. Look at the code again. Line 1 of the code now begins with a transitional doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 6. Our last step is to remove the line spacing in the <head> area. Go to COMMANDS > APPLY SOURCE FORMATTING. The blank lines in your code disappear. 7. Save your page. Tweaking the Page
I also envision this background to be the frame for our winter picture, so in my case I will use the background slice within a newly created layer.
With our background layer in place, it's time to take Frosty apart. One of the reasons I wanted to use the FW-generated HTML page is that it gives us the final position of each snowman piece and has all the layers in place with the right Z-index. We could have done all this from scratch creating all the necessary layers (as we did with the background layer) but why make all that extra work for ourselves when we don't have to? What we will do next is set the Drag Layer behavior for each layer, and then move the pieces underneath or to the right of the background.
Reader Feedback: Page 1 of 1
Enterprise Open Source Magazine Latest Stories . . .
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||