ebook img

AdvancED Flex application development : building rich media X PDF

509 Pages·10.291 MB·English
by  R Blanket al
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview AdvancED Flex application development : building rich media X

8962FM.qxd 11/9/07 1:22 PM Page i AdvancED Flex Application Development Building Rich Media X R Blank Hasan Otuome Omar Gonzalez Chris Charlton 8962FM.qxd 11/9/07 1:22 PM Page ii AdvancED Flex Application Development: Building Rich Media X Copyright © 2008 by R Blank, Hasan Otuome, Omar Gonzalez, and Chris Charlton All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission ofthe copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-896-2 ISBN-10 (pbk): 1-59059-896-2 ISBN-13 (electronic): 978-1-4302-0441-1 ISBN-10 (electronic): 1-4302-0441-9 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner,with no intention of infringement of the trademark. Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected],or visit www.springeronline.com. For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected],or visit www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution 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. The source code for this book is freely available to readers at www.friendsofed.comin the Downloads section. Credits Lead Editor Production Editor Ben Renow-Clarke Jill Ellis Technical Reviewer Compositor Lar Drolet Dina Quan Editorial Board Proofreader Steve Anglin, Ewan Buckingham, Lisa Hamilton Gary Cornell, Jonathan Gennick, Jason Gilmore, Jonathan Hassell, Indexer Chris Mills, Matthew Moodie, Broccoli Information Management Jeffrey Pepper, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Artist Tom Welsh Kinetic Publishing Services, LLC Project Manager Cover Image Designer Sofia Marchant Bruce Tang Copy Editor Interior and Cover Designer Ami Knox Kurt Krames Associate Production Director Manufacturing Director Kari Brooks-Copony Tom Debolski 8962FM.qxd 11/9/07 1:22 PM Page iii To my parents, Marion and Martin, and my brother, Jonathan, for all they have given me in life, especially the ability to communicate my thoughts fluently, the confidence to do so abundantly,and the drive to keep doing it.Tomy amazing team at Almer/Blank who make it possible for me to do everything I do, through their outstanding skills, vision, imagination, drive, and dedication. To Stephanie, who for years told me that I would write a book, whether I wanted to or not.And, of course, to Puck and Pippin, who never once complained when I stayed up writing till 4 a.m., even if that meant I forgot to feed them. RBlank To God and my mom for my life. I would not be here without you. To my beautiful wife for the understanding you showed. Your sacrifice will never be forgotten. To the best children a father could ever ask for. Daddy loves you more than you’ll ever know. Hasan Otuome Idedicate this book to my parents, Juan and Maria Reyna Gonzalez. I cannot put in words the love and gratitude I have for everything you have ever done for me. I would not be hereif it weren’t for everything you’ve taught me—thank you. Quisiera dedicar este libro a mis padres, Juan y Maria Reyna Gonzalez. No hay palabras para expresar el amor y agradecimiento por todo lo que han hecho por mi. No estaria aqui sin la educacion que me dieron ustedes—gracias. Omar Gonzalez To my loved ones—as always I share my love, dedication, and dreams. Chris Charlton 8962FM.qxd 11/9/07 1:22 PM Page iv CONTENTS AT A GLANCE Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii About the Cover Image Designer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Layout Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx PART 1 PLANNING THE RMX Chapter 1 Introduction to Flex 2 Applications. . . . . . . . . . . . . . . . . . . . . 3 Chapter 2 Defining the Application: Introducing the RMX. . . . . . . . . . . 19 Chapter 3 Planning the Application: Building the RMX . . . . . . . . . . . . . 43 PART 2 BUILDING THE RMX CORE FUNCTIONS Chapter 4 Preparing to Get to Work. . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Chapter 5 Styling Flex. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Chapter 6 Collecting and Working with Aggregated Content. . . . . . . . 145 Chapter 7 Secondary Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Chapter 8 Forms and Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Chapter 9 User Communications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Chapter 10 Working with Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 Chapter 11 Advertising and Flex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 iv 8962FM.qxd 11/9/07 1:22 PM Page v PART 3 BUILDING OUT NEW FEATURES Chapter 12 Building the Blog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Chapter 13 Building the Jobs Board. . . . . . . . . . . . . . . . . . . . . . . . . . . 337 Chapter 14 Building the Event Calendar . . . . . . . . . . . . . . . . . . . . . . . 371 Chapter 15 Ideas for the Future: Extending the RMX. . . . . . . . . . . . . . 391 PART 4 SPECIAL TOPICS Chapter 16 RSLs and Persistent Framework Caching . . . . . . . . . . . . . . 419 Chapter 17 Search Engine Optimization for Flex . . . . . . . . . . . . . . . . . 429 Chapter 18 Building an Audio Visualizer in Flex. . . . . . . . . . . . . . . . . . 443 Appendix The Evolving Flex Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . 457 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 v 8962FM.qxd 11/9/07 1:22 PM Page vi CONTENTS Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii About the Cover Image Designer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Layout Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx PART 1 PLANNING THE RMX Chapter 1 Introduction to Flex 2 Applications. . . . . . . . . . . . . . . . . . . . . 3 The Flash Platform and Web 2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Just what is this Web 2.0? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 What’s Flash got to do with it? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Ubiquity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Reliability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Experience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 ActionScript 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 What is Flex?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 To Flex or not to Flex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Is it an application?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Does it use components heavily? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 How much custom skinning will be required?. . . . . . . . . . . . . . . . . . . . . . . . . 14 Flexers are from Mars, Flashers are from Venus. . . . . . . . . . . . . . . . . . . . . . . . . . 14 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Chapter 2 Defining the Application: Introducing the RMX. . . . . . . . . . . 19 The amazing Adobe communities. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 The idea for the RMX is born . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Defining the goals and functionality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Understanding the network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 Independent application at an independent URL. . . . . . . . . . . . . . . . . . . . . 23 Flexible feature set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 vi 8962FM.qxd 11/9/07 1:22 PM Page vii CONTENTS Core features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Event calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Membership communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Forums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Blogs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Front pages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Video network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Jobs board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Social media functionality. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Tagging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Commenting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Rating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Sharing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 Flagging and moderation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 RSS feed generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Advertising . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 The tools for the task. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Aword on GNU GPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Application platform. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Flash and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 LAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 FlexTube.tv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Drupal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 FFMPEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 OpenAds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 EdgeCast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 AMFPHP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Design and development tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Adobe Illustrator,Fireworks, and Flash. . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Adobe Flex Builder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Flex-Ajax Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 OmniGraffle Professional . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Firefox plug-ins. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Project management tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 MS Project and Project Insight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Mantis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Subversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Chapter 3 Planning the Application: Building the RMX . . . . . . . . . . . . . 43 Anote on complexity. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 Stages of planning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 Defining the business requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Creating the wireframes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 Authoring the project specification. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 vii 8962FM.qxd 11/9/07 1:22 PM Page viii CONTENTS Building the project plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Planning the plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Creating the project guide. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Creating the project schedule. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 Getting into development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Designs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 Technical specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Technical documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Testing and release. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Release . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 Specific RMX planning considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 General considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Web page vs. application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Searching and filtering. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 The nature of the network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 Central navigational elements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 The control panels. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 The site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Planning parts of the RMX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 The jobs board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 The spec and wires. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 The event calendar. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 The spec and wires. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 The group control panel vs. the network control panel . . . . . . . . . . . . . . . . . . . 89 The spec and wires. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 PART 2 BUILDING THE RMX CORE FUNCTIONS Chapter 4 Preparing to Get to Work. . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Setting up the development environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Flex Builder stand-alone or Eclipse plug-in installation. . . . . . . . . . . . . . . . . . . . 96 Source control, SVN, and Subclipse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 PHPEclipse. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Planning your application’s structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Database design. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Project structure and namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 New project template . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 The main application class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Data transfer objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 Final pointers before writing code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Variable and method naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Commenting source control commits. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Preparing code for documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 viii 8962FM.qxd 11/9/07 1:22 PM Page ix CONTENTS Chapter 5 Styling Flex. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 The Flex implementation of CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 CSS 101: A primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Tag selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Class selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Inline CSS styling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 The <mx:Style/> tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 ActionScript-driven styling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 The setStyle method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 The Embed metadata tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Asset libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Component-unique properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 Scale 9 formatting feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Runtime CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 The Flex Style Explorer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 Styling considerations and the RMX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 RMX styling obstacles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Hand cursors on Accordion headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Custom ItemRenderers with rollover skins . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Chapter 6 Collecting and Working with Aggregated Content. . . . . . . . 145 Data sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 MySQL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 XML structures and schemas. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 XML web feeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Sharing outside the network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Sharing permalinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 Sharing by e-mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Sharing and embedding video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Embedding with JavaScript. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Embedding with XHTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Using RSS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Attaching files to RSS feeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 XML namespaces and extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 MRSS and syndicating to the Adobe Media Player . . . . . . . . . . . . . . . . . . . 162 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Chapter 7 Secondary Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Creating the database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Building the Products class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 ix 8962FM.qxd 11/9/07 1:22 PM Page x CONTENTS Building a Flex interface for Products.php . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Time to import your classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Handling navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Processing the results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Search integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Upgrading the Flex application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Modularization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Enhancing the code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 History management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Chapter 8 Forms and Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Data transfer objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Why use DTOs? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Setting up a DTO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Setting up a form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 The <mx:Form/> tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 The <mx:FormHeading/> tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 The <mx:FormItem/> tag. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Handling user input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 Collecting the user input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 Validating user input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 The validators array. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Using the Validator classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209 The EmailValidator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 More validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 The restrict property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 The maxChars property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 Confirming the password and e-mail address . . . . . . . . . . . . . . . . . . . . . . . . 215 Submitting the form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 Validating the form on submission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 Managing remoting calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 Forms, PHP, and security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Security: Being careful with user-supplied content. . . . . . . . . . . . . . . . . . . . . . 226 Accepting text and dealing with form data. . . . . . . . . . . . . . . . . . . . . . . . 227 Accepting user-generated HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Accepting user-generated CSS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 Chapter 9 User Communications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Building the communications control panel . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 In the beginning there was ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 Overview of the ServiceUtil class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 ActionScript interfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 Class exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 MXML development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243 Time to organize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245 x

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.