1. Trang chủ
  2. » Công Nghệ Thông Tin

Addison wesley flash and XML a developers guide nov 2001 ISBN 0201729202

527 151 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 527
Dung lượng 5,77 MB

Nội dung

• Table of Contents Flash and XML: A Developer's Guide By Dov Jacobson, Jesse Jacobson Publisher : Addison Wesley Pub Date : November 20, 2001 ISBN : 0-201-72920-2 Pages : 368 "This book is an exceptional training manual to bring a web developer or flash designer with scripting skills into an entirely new world of coding."Christopher Ian Smith, XML Developer, RespondTV.com "This is a 'must-read' for any Flash developer."-John Paul Rawlins, Editor FlashNewz.com Flash and XML shows designers and developers how to integrate these powerful technologies and create dynamic web sites With this thoroughly readable guide you take Flash to the next level, interfacing ActionScript with XML Empower your Flash projects with dynamic content, backend databases, server-based applications, peer-to-peer, and more Flash and XML is a tutorial that brings you up to speed on both technologies, offering clear and concise explanations In addition, this book presents a number of important web technologies, including PHP, MySQL, and sockets It shows how to work with these technologies to create n-tier, interactive systems that access the full resources of the Internet Sample projects (trivia game, XML browser, simple chat) showcase the capabilities of Flash and XML together and demonstrate important concepts, approaches, and techniques • Table of Contents Flash and XML: A Developer's Guide By Dov Jacobson, Jesse Jacobson Publisher : Addison Wesley Pub Date : November 20, 2001 ISBN : 0-201-72920-2 Pages : 368 Copyright Preface What's Up? Don't Stop! Who Are You? Why? Typographic Conventions Acknowledgments Chapter 1 Flash Basics The Background of Flash Practical Flash Event-Driven Graphics Building a Button Constructing a Round Making Keyframes Constructing the Responses Finishing Features Conclusion—and Beyond Chapter 2 Flash ActionScript: Objects and Events Object Orientation Concepts Object-Oriented Theory vs ActionScript Reality Flash Objects Programmable Button Data Encapsulation Conclusion Chapter 3 More ActionScript: Data-Driven Interfaces Data-Driven Decisions Data-Driven Everything Isolating the Data Dynamic Creation of Graphics Multiple Questions Conclusion Chapter 4 XML Fundamentals XML Background How XML Works Designing the Data Conclusion Chapter 5 XML Structure Element Name Start Tag End Tag Attributes Text (Character Data) Entity References Comments Processor Instructions Conclusion Chapter 6 XML Validation: DTD Purpose of DTD Valid XML and Well-Formed XML DTD Declarations Entities Namespace Conclusion Chapter 7 HTTP Connection Characteristics of HTTP Structure of HTTP Loading Data from a File Making a Self-Loading High Score Display Object-Oriented Implementation Data File Flash Download Security Conclusion Chapter 8 XML Connection Downloading XML XML.load Debugging Flash Event-Driven Functionality Conclusion Chapter 9 Recursive Approach Event-Driven Code Recursive Design Recursion Recursion in Practice Graphic XML Browser Interactive Node Viewer Conclusion Chapter 10 XML Server XML Online Dedicated XML Server Middle-Tier Solutions PHP Basics PHP and XML XML-Driven Flash Client Conclusion Chapter 11 Database Fundamentals Background Advantages of a DBMS Advantages of SQL Keys Conclusion Chapter 12 SQL Syntax Varieties of SQL Prompt Tables Guidelines for Building a Table Types of Data Adding Data to Tables Reading Records from the Table Conclusion Chapter 13 Serving from SQL Connecting to a Database Interaction with a Database Parsing Commands Fetching a Row Trial-and-Error Approach Scalable Alternative Conclusion Chapter 14 XML Upload Flash Client Uploading to PHP Conclusion Chapter 15 Two-Way XML Event-Driven Parsing Building the PHP Parser Conclusion Chapter 16 Cookies ActionScript XML Objects Stateless Persistence Conclusion Chapter 17 Three Tiers Database Flexible Middle Tier Client Tier Conclusion Chapter 18 Flash to the World Domain Perimeter PHP Proxy Client RSS File RSS Browser Conclusion Chapter 19 XML Sockets Advanced Socket Programming XMLSocket Simple Socket System Simple Socket Server Conclusion Chapter 20 Multiplexed XML Sockets Chat Client with History Multiclient Server Beyond PHP Conclusion Chapter 21 End Note Appendix A Microsoft Compatibility ASP Code with Flash IIS and PHP Appendix B Scalable Vector Graphics (SVG) Appendix C Tools and Sources Network Tool Servers XML Tools PHP Tools MySQL Tools Flash Copyright Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein The publisher offers discounts on this book when ordered in quantity for special sales For more information, please contact: Pearson Education Corporate Sales Division 201 W 103rd Street Indianapolis, IN 46290 (800) 428-5331 corpsales@pearsoned.com Visit AW on the Web: www.aw.com/cseng/ Library of Congress Cataloging-in-Publication Data Jacobson, Dov Flash and XML : a developer's guide / Dov Jacobson and Jesse Jacobson p cm Includes index ISBN 0-201-72920-2 (alk paper) 1 XML (Document markup language) Web sites—Design Flash (Computer file) I Jacobson, Jesse II Title QA 76.76.H94 J334 2002 005.7'2—dc21 2001045738 Copyright © 2002 by Dov Jacobson and Jesse Jacobson All rights reserved No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher Printed in the United States of America Published simultaneously in Canada For information on obtaining permission for use of material from this work, please submit a written request to: Pearson Education, Inc Rights and Contracts Department 75 Arlington Street, Suite 300 Boston, MA 02116 Fax: (617) 848-7047 Text printed on recycled paper 1 2 3 4 5 6 7 8 9 10—DOC—0504030201 First printing, October 2001 Dedication To three we love— Shez, Judy, and Anna Leah Jacobson Send Precondition Failed error code to the client It asked you to update the XML file but neglected to send the new data ActionScript Else Dim fs Dim filename Dim backname Dim thisfile Response.ContentType="text/xml" Response.Write Request.Form("xml") Request is the data object that arrived from the Client Response is the data that the server is sending back in return These lines tell the client to get ready for XML data and then echo back the XML we just received ActionScript filename = server.mappath( "quiz.xml" ) backname = server.mappath( "old/quiz xml") We need the operating system's names for the files that the web server knows as "quiz.xml" and "old/quiz.xml" (These files do not have to actually exist In particular the "old/" one might not yet have been created.) Rather than a relative address in a space limited to the Internet domain, the operating system uses a disk identifier and directory path on the server machine to reach the physical file ActionScript Set fs = CreateObject("Scripting.FileSystemObject") This fs object is not a file handle It is a file system handle It is the object that performs all the file-oriented operations we need Set thisfile= fs.GetFile( filename ) thisfile.Copy( backname ) We can address a file without opening it and instruct it to make a copy of itself as the backup file If there is a backup file already, it is overwritten Set thisfile= fs.OpenTextFile(filename,2,True) thisfile.write( Request.Form( "xml") ) thisfile.close Now we open the file for writing and write into it the string representation of the XML object that was posted backname = server.mappath( "old/" & Year(Date()) & Month(Date()) & Day(Date()) & ".xml") Set thisfile= fs.GetFile( filename ) thisfile.Copy( backname ) To create a permanent backup that will not be overwritten by the next update, we make an archive copy of today's new XML using today's date to name it Set thisfile = Nothing Set fs = Nothing End if Then we recover the memory Else Response.Write "Look I found it!" Response.Write XMLstr End if %> IIS and PHP It is not necessary to learn ASP, even if you are compelled to work with a Microsoft server and operating system Internet Information Server will support PHP 4 Success has even been reported with the advanced socket manipulations required for XML sockets, using IIS server and Windows 2K, as long as the -enablesockets directive has been compiled into PHP (This is not the default.) Appendix B Scalable Vector Graphics (SVG) Our work with XML uses the language to encode fairly abstract data like quiz questions or player identities We use Flash to convert these into onscreen displays Typography, layout and illustration—as well as animation and interaction—are employed to create a display that beautifies the data and hopefully clarifies its meaning There is a huge divide between the XML data and the graphics used to display it The graph ics are transmitted as swf files in Flash's proprietary encoding The graphic data exist in a different address space not directly accessible to the functions that manipulate the XML data This divide may disappear A very well-supported effort is underway to create an XML vocabulary for web graphics The aim of this effort is universal browser support of a nonproprietary, highly sophisticated graphic language that meshes cleanly with the other technologies of the web Vector graphics, typography, and scripting are valued by this consortium The standard that resulted from their efforts is called Scalable Vector Graphics (SVG) Its functionality overlaps the SWF functionality—it has a set of graphic primitives that are similar—but is somewhat more sophisticated The graphic primitives include the shapes of swf plus rectangles, circles, and more sophisticated bezier curves The fill effects are like those of Flash, including outlines, gradients, masking, pattern fills, and transparency (all animatable), and also include plugin functionality similar to Photoshop filters, which can be applied to lines as well as fills SVG attaches font characteristics to true text: Rather than being buried in an swf file, pure text is exposed to search engines and indexing robots while retaining all the flexible styling ability that a Flash file would have All the tools of an interactive page can be integrated seamlessly into an SVG graphic: JavaScript, DHTML, XHTML, and CSS The elements of a graphic can be distributed across many files or across many web sites, allowing great efficiencies of maintenance and flexibility of presentation to those who plan their site well Surprisingly, despite the fact that these graphics are presented in plain text XML, the early tests show files that are somewhat smaller than the matching SWF files (possibly because they were hand-encoded?) However, automatic zip compression will be introduced to the web at the same time as SVG The text of SVG compresses easily, and the standard seems far more efficient than swf The future SVG-enabled browser (IE 6.0?) will be the equivalent of today's browsers with Flash player plugins There are some important differences to look forward to First, the SVG player will not be a proprietary system but will have support from multiple vendors This is good and bad Multiple vendors will compete for high-performance, highly compliant implementations, and that tends to result in better products brought rapidly to market On the other hand, veteran web developers will recognize the pain in store for them In the past, we have had to straddle (for example) the slightly different renderings of HTML, Java, and scripting languages of Netscape, AOL, and Microsoft The dream of a page rendering identically on different platforms will always be a dream Maybe if we are lucky, it will display correctly on multiple platforms But the significance of SVG is greater than second-sourcing a player plugin It is useful to have the graphics and script exposed in the transparent coding of XML Transparent source code raises issues of site and transactional security And it challenges (as most web protocols do) the competitive instinct to treat source code as a trade secret Yet it opens up a new world of tremendously dynamic web entities that will make today's Flash sites seem stiff and unresponsive And it invites the creation of a multiplicity of tools and libraries that push the envelope creatively, technically, and in fulfilling the needs of niche communities Even more significant than the transparency of the XML code is the integration of scripting, graphics, HTML, and XML into a single Document Object Model, at the core of the browser An ActionScript programmer now cannot do something as simple as read an XML file containing (for example) sales data and create a simple area chart from it While the XML data is accessible, the points in a polygon are not In an SVG environment, this code would be trivially simple In fact, since the incoming sales information and the displayable SVG graph are both legitimate XML codings, the graphing function could exist in as simple a form as an XLS transformation file Today a stock-charting site delivers dumb gif files In the future it might combine XML-based data, a charting rubric (expressed in XLS and rendered in SVG) within a publisher's presentation coded in some kind of HTML Each of these files is simple and independent Each can be provided by a different supplier, allowing a web of flexible relationships and profound personalization When (and if) SVG will become ubiquitous is unknown, but momentum seems to be building Macromedia has expressed support for the standard IBM, Corel, and Adobe have been even more enthusiastic Recent advances in Flash, starting with ECMA coding and XML readiness in version 5.0, can be seen as steps in the direction of this emergent standard Hopefully the paths of Flash and SVG will continue to converge and the skills we are developing in ActionScript code and in XML will serve us well in the future Appendix C Tools and Sources A much better version of this appendix is online at flashandxml.com, along with code samples, bonus tracks, and bulletin boards The online version features live links, free demos, and special programs for our readers Following are the tools we used during the writing of the book This appendix is not meant to be an exhaustive view of the market or an analytical comparison of competitors For example, we have low demands on development tools Our work is not high-volume production but cautious experimentation About 90 percent of the code was handwritten in very simple text editors (often web-based editors) The only tool that was truly indispensable (besides the Google search engine) was the Iris packet sniffer Network Tool Iris Iris is a packet sniffer: It monitors all the traffic going through a network connection Iris can inspect every bit of traffic in a very lucid context Without a tool like this, it is difficult to perfect a distributed network application We are forced to guess what each application sends based on the response of the other applications Very tough Directly examining packet dumps seems like tedious work, but it is precise and always illuminating If you are building a system around connectivity, you ought to know what is really going on This tool is beautifully made and works flawlessly Despite its considerable expense, it will certainly save time Thanks to Dave Rosenbaum who insists: "Don't assume Test," and to Nigel Head who showed us how Servers CULT XML Socket Server The first commercial third party socket server This product seems promising but was not ready for testing as we went to press XML Tools XML Spy This tool is engineered with enthusiasm and marketed with gusto Fortunately, that marketing gusto has been toned down, and it no longer stamps its own name into every file you write! Like Real Networks, though, it still exhibits an unattractive desire to make itself the default app on dozens of file types Engineering enthusiasm makes for a finely built, highly featured product But here too there is a sense of overkill Maybe these guys need a harder job! Instead, they overinvented the user interface XML documents are straight tree structures Trees are displayed with similar mechanisms in Mac and Windows Explorer and almost every app Think of the directory structure you see in a file operation, with folders that open and contain other folders XML Spy visualizes trees as a clutter of nested boxes This never made sense to us, although it might make sense to other people We disregarded that very central aspect of the product, which promised a path to visual data design, and instead used XML Spy only as XML source editor, validator, and file manager As such, it is excellent—well engineered and a pleasure to operate EditML We spent less time with this XML editor It is more modest than XML Spy, but, in our clumsy hands, it was also a bit less sturdy It is designed as not only a tool but an introduction to the technology Its help screens are excellent for teaching XML to the novice The product has an organization that is simple and easy to understand, although gratuitously cute icons give it an elementary school feel MS XML Notepad This is a very simple and easy to use tool, but it is insufficient for designing valid XML But the learning curve is a tiny bump, the price is zero, and the display of tree structure is free of the excessive creativity that makes the other two products annoying to use If you do not care about DTDs but you do care about money, this little gift from Bill Gates might be just fine Web Sources www.w3.org/TR/REC-xml The definitive word on XML, literally editml.com/Samples.htm A nice set of simple starter sample XML files xmlpitstop.com A pleasant starting point with a fun attitude, a generous sysop, and hundreds of annotated links userland.com A highly active center for development of RSS, SOAP, and other interactive XML technologies The focus is on pathways for independent servers to interoperate—such as automated content publishing and aggregation—and on functionality as content! PHP Tools PHP Coder This is a very rich IDE (integrated development environment) for PHP We used it a little bit, but we got our (beta) copy after we had become comfortable with simpler editors Our projects were small, single-file experiments If we were beginning a larger PHP project, this tool would probably be at the heart In that case, the productivity payback for the considerable installation effort and the light learning curve would probably be pretty quick Sources Zend.com The commercial arm of the PHP's hardworking mentors PHPBuilder.com An independent development oriented site with great community MySQL Tools MySQLEditor This is a mild pain reliever for assembling and interacting with a MySQL database It makes communication a bit easier and helps visualization of the results Version 0.3 (available to us) was still fairly rough Source MySQL.com The source for everything including an excellent downloadable documentation Flash Sources macromedia.flash (newsgroup) An all-ages show, with some very patient flash masters…and much much noise flashkit.com A much more advanced group Not for newbies A rich web site with excellent discussions and heaps of resources Also a conference in Sydney and Los Angeles, that addresses the accomplished Flash user figtree.com Top educators in advanced ActionScript (like Brendan Hall) The real thing moock.com Colin Moock approaches technology with creativity and generosity flashforward (conference) Held in both San Francisco and New York and drenched in information and attitude Wear black, be pierced, and make sure it can all be expensed ... Chapter 13 Serving from SQL Connecting to a Database Interaction with a Database Parsing Commands Fetching a Row Trial -and- Error Approach Scalable Alternative Conclusion Chapter 14 XML Upload Flash Client... O'Brien, Executive Editor at Addison- Wesley For their able support: her editorial assistants, Alicia Carey and Mariann Kourafas For his imaginative, clearheaded thinking on many aspects of this book, and especially for its handsome looks: Kevin Smith of stateless designs... For their enthusiasm and their insights: Colin Moock and other FlashForward speakers, Urami and other macromedia .flash posters, and the lively community at FlashKit.com For their support—financial and creative—of the real-life version of the game described in this book: webmaster Garth Moore and producer Zoë

Ngày đăng: 26/03/2019, 16:32