Tải bản đầy đủ (.pdf) (529 trang)

Flash and PHP bible

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (14.22 MB, 529 trang )

www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page iii

Flash and PHP
Bible
®

Matthew Keefe

www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page i

Flash and PHP
Bible
®



www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page ii

www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page iii

Flash and PHP
Bible
®

Matthew Keefe

www.it-ebooks.info



01_258248 ffirs.qxp

3/28/08

1:34 PM

Page iv

Flash® and PHP Bible
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com

Copyright © 2008 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-25824-8
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
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, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization
through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA
01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Legal
Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317)
572-4355, or online at />LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO

REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE
CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED
OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED
HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING
THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER
PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT
PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE
LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS
REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION
DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE
ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS
SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR
DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services or to obtain technical support, please contact our Customer
Care Department within the U.S. at (800) 762-2974, outside the U.S. at (317) 572-3993 or fax (317) 572-4002.
Library of Congress Control Number: 2008925780
Trademarks: Wiley, and the Wiley logo, and related trade dress are trademarks or registered trademarks of John Wiley &
Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission.
Flash is a registered trademark of Adobe Systems Incorporated in the United States and/or other countries. All other
trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or
vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in
electronic books.

www.it-ebooks.info


01_258248 ffirs.qxp


3/28/08

1:34 PM

Page v

About the Author
Matthew Keefe is a new-media designer and developer, with a strong background in application
development for the Web and offline. Originally a full-time graphic artist, he found that much of
the programming associated with his design work was being outsourced. Matt quickly learned programming for the web and uncovered a valuable but little-known skill set in this industry, that skill
being the ability to build a site and also the ability to powerfully design it. This was preferred by
clients because they could do the entire project with one studio.
Matt has worked with companies such as Delphi, PhotoshopCafe, Kineticz Interactive, and Organi
Studios to name a few. His work has been published in How To Wow with Flash (Peachpit Press) for
which he was a contributing author and technical editor. Matt has also recently finished up work
as the technical editor for Essential ActionScript 3 (Adobe Dev Library).
Examples of his work can be found in his personal portfolio at mkeefe.com.

www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page vi

To my loving father.


Credits
Senior Acquisitions Editor
Stephanie McComb

Project Coordinator
Erin Smith

Project Editor
Beth Taylor

Graphics and Production Specialists
Claudia Bell
Jennifer Mayberry
Ronald Terry

Technical Editor
Navid Mitchell

Quality Control Technician
Susan Moritz

Copy Editor
Kim Heusel

Media Development Project Manager
Laura Moss-Hollister

Editorial Manager
Robyn Siesky


Media Development Coordinator
Jenny Swisher

Business Manager
Amy Knies

Associate Producer
Shawn Patrick

Sr. Marketing Manager
Sandy Smith
Vice President and Executive Group
Publisher
Richard Swadley
Vice President and Executive Publisher
Bob Ipsen

Proofreading
Christine Sabooni
Indexing
Broccoli Information Management

Vice President and Publisher
Barry Pruett

www.it-ebooks.info


01_258248 ffirs.qxp


3/28/08

1:34 PM

Page vii

M

acromedia . . . errr Adobe Flash is hands down one of the most impressive and powerful
tools for any designer when it comes to bringing an experience to a user. And as Flash
continues to evolve not just web, for which it got popular, but also offline users with platform developments such as Adobe AIR and the wide range of third-party tools that can be used.
But to a hardcore developer Flash has had a bad rap. Mainly due to the fact that AS 1.0 was an
awkward, gawky, and immature language. Compared to other languages popular when AS 1.0 was
introduced, it wasn’t something to be taken seriously in a developer’s eye and rightfully so. But
then if Flash is so hindering, why am I even reading a foreword for a book on the subject?
Things have changed, drastically changed. AS 3.0 is here and it is one of the best languages around
when understood. AS 2.0 was a step in the right direction, but AS 3.0 has surpassed every Flash
developer’s dreams. Small file sizes, very solid performance, and even some data handling that
rivals Java, so really there isn’t a developer who can say it is no longer a concrete language.
And with AS 3.0 a new era of data handling is introduced into Flash. And not only with Flash, but
when you start mixing in PHP5, MySQL 5, ASP, AMFPHP, and other methods of handling data, the
possibilities open up into a new realm. Data is up for grabs in AS 3.0, and it’s only a matter of reading a book like this to apply it. Sockets, xml, web services, and other external data sources allow a
Flash developer to get really dirty in a data source and update the content without touching the
Flash files again. The benefit is allowing more time to develop an engaging user experience without
worrying about repeat edits, a client’s future budget, etc. It actually allows a serious Flash developer to continue to work with data sources as they are developed and concentrate on the benefits
of finessing the content itself, rather than what the content is at the time of development that can
change on a client’s whim later on.
Gone are the days that you would build a client’s website, have a ton of large swfs, only for them to
constantly need updates for photos, copy, catalog items, etc. In this book you will read how to utilize the methods mentioned to broaden your understanding of taking out the last restriction to

knowing powerful Flash, updating without ever republishing, opening up an FLA, or worrying if
the client sent you the right copy, image, or other asset.
Get rid of the idea that a Flash project is now plagued with an ever-so-changing fla file and
embrace the idea of run-time content generation.
Michael Minor
Director of Interactive Media
invertedCreative.com

vii
www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page viii

www.it-ebooks.info


01_258248 ffirs.qxp

3/28/08

1:34 PM

Page ix


I

would like to thank Laura Sinise for helping me to get started. This book would not have been
possible without the following people: Senior Acquisitions Editor, Stephanie McComb; Project
Editor, Beth Taylor; Copy Editor, Kim Heusel; Technical Editor, Navid Mitchell; and Mary Keefe.
I would also like to thank my friends Colin, Philip, Brooke, Frank, Jimmy, and Daz and my cousin
Teisha for their huge amount of support. And lastly, I would like to thank my family for their understanding and patience while I was locked away in my office during all hours of the night.

ix
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page x

About the Author ............................................................................................................................v
Foreword ......................................................................................................................................vii
Acknowledgments..........................................................................................................................ix
Introduction ................................................................................................................................xix

Part I: Understanding the Basics . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Chapter 1: Getting Started with Flash and PHP ..............................................................................3
Chapter 2: Exploring Flash and PHP ............................................................................................37
Chapter 3: Getting Connected ......................................................................................................63

Chapter 4: Working with Data ......................................................................................................85
Chapter 5: Interacting with the User ............................................................................................99
Chapter 6: Working with Cookies ..............................................................................................113

Part II: Developing Interactive Content . . . . . . . . . . . . . . . . . . 125
Chapter 7: Maintaining Security while Working with User Input ................................................127
Chapter 8: Using Sockets ............................................................................................................153

Part III: Extending Flash and PHP . . . . . . . . . . . . . . . . . . . . . . . 189
Chapter 9: Working with Third-Party Libraries ..........................................................................191
Chapter 10: Using Object-Oriented Programming ......................................................................219

Part IV: Developing Applications . . . . . . . . . . . . . . . . . . . . . . . 237
Chapter 11: Developing Basic Applications ................................................................................239
Chapter 12: Developing Real-World Applications ......................................................................289
Chapter 13: Using Advanced Real-World Applications................................................................335
Chapter 14: Debugging Applications ..........................................................................................381

Part V: Server, Application, and Database Maintenance . . . . . . 393
Chapter 15: Maintaining an Application......................................................................................395
Chapter 16: Maintaining a Scalable and More Efficient Server ....................................................405
Chapter 17: Building Complete Advanced Applications ..............................................................429
Index ..........................................................................................................................................487

x
www.it-ebooks.info


02_258248 ftoc.qxp


3/28/08

1:34 PM

Page xi

About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . v
Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Part I: Understanding the Basics

1

Chapter 1: Getting Started with Flash and PHP . . . . . . . . . . . . . . . . . 3
Adding Apache to a Web Server ............................................................................................3
Installing Apache for Windows....................................................................................4
Installing Apache for UNIX..........................................................................................9
Modifying Apache for Windows and UNIX ..............................................................13
Installing MySQL ................................................................................................................14
Installing MySQL for Windows..................................................................................14
Installing MySQL for UNIX ......................................................................................25
Protecting MySQL ....................................................................................................26
Setting up PHP on the Web Server ......................................................................................27
Installing PHP for Windows ......................................................................................27
Installing PHP for UNIX ............................................................................................33
Summary ............................................................................................................................35

Chapter 2: Exploring Flash and PHP . . . . . . . . . . . . . . . . . . . . . . 37

Introduction to the Web Server ..........................................................................................37
Working with .htaccess files ......................................................................................37
Protecting your content ............................................................................................38
Gathering information about Apache ........................................................................40
Using custom error documents..................................................................................42
Exploring the Basics of PHP ................................................................................................47
Understanding variables ............................................................................................47
Working with functions ............................................................................................49
Understanding control structures ..............................................................................51
Using type checking in PHP ......................................................................................56

xi
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xii

Contents

Exploring the Basics of MySQL ..........................................................................................57
Using statements ......................................................................................................57
Conditions ................................................................................................................58
Exploring Flash ..................................................................................................................59
Flash IDE ..................................................................................................................59

Alternative editors ....................................................................................................61
Flash-enabled devices ................................................................................................62
Moving forward ........................................................................................................62
Summary ............................................................................................................................62

Chapter 3: Getting Connected . . . . . . . . . . . . . . . . . . . . . . . . . 63
Understanding Communications in Flash............................................................................63
Determining the status of PHP ..................................................................................64
Working with various connection types ....................................................................65
Connecting Flash to PHP ....................................................................................................69
Connecting PHP to MySQL ................................................................................................73
Determining the status of MySQL ............................................................................73
Connecting to MySQL ..............................................................................................74
Bringing it all together ..............................................................................................77
Summary ............................................................................................................................84

Chapter 4: Working with Data . . . . . . . . . . . . . . . . . . . . . . . . . 85
Loading Data in Flash..........................................................................................................85
Understanding the classes used to load data ..............................................................86
Putting it all together ................................................................................................87
Handling Loaded Data ........................................................................................................88
One-way loading ......................................................................................................88
Two-way loading ......................................................................................................88
Loading XML in Flash ........................................................................................................89
Working with XML in PHP..................................................................................................92
Loading XML ............................................................................................................92
Sending XML ............................................................................................................93
Loading Images Using PHP ................................................................................................95
Setting up the image loader ......................................................................................96
Summary ............................................................................................................................98


Chapter 5: Interacting with the User . . . . . . . . . . . . . . . . . . . . . . 99
Form Development Using Flash ..........................................................................................99
Creating a Contact Form ..................................................................................................101
Calling the PHP ......................................................................................................103
Contact form event handlers....................................................................................103
Mailing in PHP ........................................................................................................105
Login Module in Flash ......................................................................................................106
Code skeleton..........................................................................................................106
Login event handlers ..............................................................................................107
Server integration for login module ........................................................................110
Summary ..........................................................................................................................111

xii
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xiii

Contents

Chapter 6: Working with Cookies . . . . . . . . . . . . . . . . . . . . . . . 113
Loading Cookies................................................................................................................113
Using cookies with PHP ..........................................................................................114

Using cookies in Flash ............................................................................................118
Discovering the benefits of using PHP cookies ........................................................122
Summary ..........................................................................................................................124

Part II: Developing Interactive Content

125

Chapter 7: Maintaining Security while Working with User Input . . . . . . 127
Using Caution with User Input..........................................................................................127
Safely handling file uploads ....................................................................................128
Checking for valid input..........................................................................................131
Cleaning User Data............................................................................................................132
Sanitizing the data ..................................................................................................133
Properly cleaning HTML data ..................................................................................136
Storing Data ......................................................................................................................136
Securely writing to a file ..........................................................................................137
Creating and storing a safe password using PHP......................................................141
Returning Data ..................................................................................................................143
Securely returning data............................................................................................143
Using a more secure approach for returning data ....................................................144
Understanding the Flash Security Sandbox ......................................................................145
Setting the sandbox type..........................................................................................145
Using the sandboxType property ............................................................................145
Determining the active sandbox ..............................................................................147
Ensuring an application cannot be shared ..............................................................151
Summary ..........................................................................................................................152

Chapter 8: Using Sockets . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Understanding Sockets......................................................................................................153

Security in sockets ..................................................................................................154
Implementing a socket server ..................................................................................154
Understanding the socket connection......................................................................154
Working with Sockets in PHP............................................................................................154
Looking for command-line version of PHP ..............................................................155
Building a socket server ..........................................................................................156
Testing the socket server..........................................................................................158
Creating a persistent socket server ..........................................................................160
Working with Sockets in Flash ..........................................................................................161
Initializing a socket connection................................................................................161
Event handlers ........................................................................................................162
Remote socket connections......................................................................................163
Using a class for socket connections ........................................................................164

xiii
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xiv

Contents

Building a Chat Client with Sockets Using Flash and PHP ................................................167
PHP socket server for the chat client........................................................................167

Connecting to the socket server ..............................................................................175
Building the Flash client ..........................................................................................177
Summary ..........................................................................................................................188

Part III: Extending Flash and PHP

189

Chapter 9: Working with Third-Party Libraries . . . . . . . . . . . . . . . . 191
Going over Third-Party Libraries ......................................................................................191
Other types of third-party libraries ..........................................................................192
Libraries in PHP ......................................................................................................193
Installing Third-Party Libraries ........................................................................................193
Installing libraries in Flash CS3 ..............................................................................193
Installing libraries in PHP ........................................................................................195
Using Third-Party Libraries ..............................................................................................196
Working with libraries in Flash CS3 ........................................................................196
Working with Libraries in PHP ................................................................................197
Glancing at AMFPHP ........................................................................................................198
AMFPHP for AS3 and PHP Developers ....................................................................198
Testing AMFPHP with a custom service ..................................................................201
Using AMFPHP in Flash ..........................................................................................205
Building a Real-World Application Using AMFPHP ..........................................................210
AMFPHP services ....................................................................................................210
ActionScript for AMFPHP integration ......................................................................216
Summary ..........................................................................................................................218

Chapter 10: Using Object-Oriented Programming . . . . . . . . . . . . . . 219
Understanding OOP..........................................................................................................219
Overview of OOP practices......................................................................................220

Using Classes in PHP ........................................................................................................225
Importing classes in PHP ........................................................................................226
Instantiation ............................................................................................................226
Multiple classes ......................................................................................................228
Using Classes in Flash ......................................................................................................229
Importing ................................................................................................................229
Document class ......................................................................................................229
Library classes ........................................................................................................230
Using Flash and PHP to Build Custom Classes ..................................................................231
Summary ..........................................................................................................................235

xiv
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xv

Contents

Part IV: Developing Applications

237

Chapter 11: Developing Basic Applications. . . . . . . . . . . . . . . . . . 239

Understanding Elements of an Application........................................................................239
Understanding application design ..........................................................................240
Finalizing the planning stage ..................................................................................242
Developing a Chat Client ..................................................................................................242
The Flash portion ....................................................................................................242
PHP for chat application..........................................................................................252
Using PHP to Develop a Photo Gallery ..............................................................................260
Developing the ActionScript ....................................................................................261
Photo gallery navigation ..........................................................................................266
PHP for the photo gallery ........................................................................................270
Using PHP to Develop an RSS Reader................................................................................274
Importing classes ....................................................................................................275
Loading the PHP......................................................................................................275
Using PHP, Flash, and MySQL to Develop a Dynamic Banner Ad ......................................279
Opening a browser window ....................................................................................281
Developing the PHP ................................................................................................283
Random selection ....................................................................................................283
Using PHP to Develop a Hit Counter ................................................................................285
Hit counter logic......................................................................................................285
Developing the Flash hit counter ............................................................................286
Summary ..........................................................................................................................287

Chapter 12: Developing Real-World Applications . . . . . . . . . . . . . . 289
Understanding Real-World Applications............................................................................289
Using PayPal in Flash ........................................................................................................290
Using POST data ....................................................................................................293
Using sendToURL ....................................................................................................294
Setting up PayPal communication............................................................................294
Using Flash and PHP to Build a Cart ................................................................................295
Designing the shopping cart ....................................................................................296

Building the PHP ....................................................................................................306
Using PHP and Flash to Build an Amazon Search Application ..........................................317
Using the Amazon Web Service ..............................................................................317
Simplifying the XML response ................................................................................319
Developing a Photo Gallery Using flickr ............................................................................326
Interfacing with the Web service..............................................................................331
Building the custom XML document ......................................................................332
Summary ..........................................................................................................................333

xv
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xvi

Contents

Chapter 13: Using Advanced Real-World Applications. . . . . . . . . . . . 335
Building a Drawing Application in Flash ..........................................................................335
Drawing API in Flash ..............................................................................................336
Using GD Library in PHP ..................................................................................................341
Generating an image in the GD library ....................................................................343
Gathering the pixel data in Flash ............................................................................345
Using Flash to Develop a Site Monitor ..............................................................................347

Developing the PHP for the site monitor ................................................................347
Using PHP to e-mail the administrator ....................................................................349
Developing the ActionScript for the site monitor ....................................................351
Using Flash to Develop a Video Player ..............................................................................359
Developing a Poll Application ..........................................................................................364
Building the PHP and MySQL..................................................................................364
Developing the ActionScript for the poll..................................................................368
Building a Simple File Editor ............................................................................................373
Summary ..........................................................................................................................380

Chapter 14: Debugging Applications . . . . . . . . . . . . . . . . . . . . . 381
Using Error Reporting in PHP ..........................................................................................381
Displaying errors for debugging ..............................................................................383
Understanding the error levels ................................................................................383
Debugging in Flash ..........................................................................................................385
Using an Alternative Trace ................................................................................................389
Summary ..........................................................................................................................392

Part V: Server, Application, and Database Maintenance

393

Chapter 15: Maintaining an Application . . . . . . . . . . . . . . . . . . . 395
Commenting Code ............................................................................................................395
Understanding styles for commenting code ............................................................396
Removing comments and debug helpers..................................................................399
Managing a ChangeLog ....................................................................................................399
Bug tracking ............................................................................................................399
Additional uses........................................................................................................400
Dynamic creation of changes ..................................................................................400

Managing Multiple Versions ..............................................................................................401
Version control applications ....................................................................................401
Version control support in CS3................................................................................401
Setting up version control........................................................................................402
Using Custom Libraries ....................................................................................................403
Using custom libraries with version control ............................................................403
Publishing an SWC..................................................................................................404
Summary ..........................................................................................................................404

xvi
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xvii

Contents

Chapter 16: Maintaining a Scalable and More Efficient Server . . . . . . . 405
Running an Updated Server ..............................................................................................405
Using automatic updates ........................................................................................406
Zend Platform..........................................................................................................406
Working with Development Installs ..................................................................................406
Building another version of Apache on the same system ..........................................406
Working with bleeding-edge technology..................................................................407

Dependencies ..........................................................................................................407
Caching and Optimizing ..................................................................................................408
Optimizing PHP ......................................................................................................408
Optimizing Apache..................................................................................................412
Optimizing MySQL ................................................................................................413
Caching ..................................................................................................................416
Installing memcached on Linux ..............................................................................416
Installing memcached on Windows ........................................................................418
Wrapping up installation for Linux and Windows ..................................................418
Managing servers ....................................................................................................420
Handling Backups ............................................................................................................421
File management ....................................................................................................421
Backup management ..............................................................................................421
Using PHP to back up databases..............................................................................424
Summary ..........................................................................................................................427

Chapter 17: Building Complete Advanced Applications . . . . . . . . . . . 429
Building a Basic Video Player ............................................................................................429
Building a Video Player in Flash and PHP ........................................................................432
Getting started ........................................................................................................432
Remoting integration ..............................................................................................437
Advanced video player development ......................................................................446
Building the VideoListItem class ..............................................................................456
Working with Video Tracking............................................................................................461
Updating the video class..........................................................................................462
updateVideoTracking method..................................................................................463
Building a User Login Component in Flash ......................................................................465
Developing the LoginWindow class ........................................................................466
Testing the login component....................................................................................473
Building the PHP login manager class......................................................................476

Adding remoting to the login component ................................................................478
Finalizing the Video Player ................................................................................................481
Using an external library ........................................................................................482
Adding the login component ..................................................................................482
Summary ..........................................................................................................................486

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487

xvii
www.it-ebooks.info


02_258248 ftoc.qxp

3/28/08

1:34 PM

Page xviii

www.it-ebooks.info


03_258248 flast.qxp

3/28/08

1:35 PM

Page xix


T

his book is a multipart exploration into Flash and PHP. Flash has been used for everything
from basic banner ads to fully functional applications across the web and desktop.

Oftentimes you can find information required to write amazing Flash applications or the serverside counterpart but rarely both. This book builds both aspects and explains the process of working with PHP in your Flash projects.
The first part of the book is a step-by-step walkthrough of the installation and configuration process for PHP and all the necessary components. Once the components are installed, the next step is
an overview of PHP and a guide to what features and techniques you will find in the book as you
continue through the chapters.
Each chapter starts off with a basic overview and then moves quickly into the relevant information,
leaving out any fluff to ensure you are getting all of the important information right away.
Part II focuses on the importance and best practices of making your applications more secure while
maintaining functionality. The topic of security is repeated throughout the various examples in this
book, but this part in particular is where you will find the majority of the security information.
Part III is extending Flash and PHP by working with various third-party applications and libraries.
This chapter finishes with an overview of AMFPHP to build more-advanced and easier-to-maintain
applications.
Part IV takes all the previous information and walks you through the process of building complete
real-world applications in Flash and PHP. These real-world applications will help you build your
own custom versions and ultimately allow you to create more-advanced and dynamic applications.

Examples and Source Files
You can find all the source code and starter files for the examples in this book on the following
web site.
www.wiley.com/go/flashandphpbible

xix
www.it-ebooks.info



03_258248 flast.qxp

3/28/08

1:35 PM

Page xx

Introduction

What You’ll Need
The ActionScript used in this book is not advanced, but a basic understanding of the fundamentals
would allow you to better understand the examples. The Flash Bible is a perfect complement to
this book and I highly recommend it.
A basic understanding of OOP practices would help you in the second portion of the book but is
not required to understand the examples overall. You may want to pick up a book on advanced
OOP practices to gain a more thorough understanding of the topic.
The PHP used in this book is assuming a very basic understanding of the subject. This means you
will not only learn the advanced topics but how to get there by starting at the beginning. PHP also
allows you to develop in a class-based format, so that will be utilized in the full-application chapters to ensure you are building a more complete and updatable application.
The last thing you will need is an Internet connection to download the code for the book and work
with some of the third-party services. This is not used in the entire book, but to get the full experience the Internet connection will be needed.
That is everything you will need. Now is the time to jump in. Chapter 1 is only a few pages away.

xx
www.it-ebooks.info


04_258248 pp01.qxp


3/28/08

1:36 PM

Page 1

Understanding
the Basics
IN THIS PART
Chapter 1
Getting Started with Flash
and PHP

Chapter 2
Exploring Flash and PHP

Chapter 3
Getting Connected

Chapter 4
Working with Data

Chapter 5
Interacting with the User

Chapter 6
Working with Cookies

www.it-ebooks.info



04_258248 pp01.qxp

3/28/08

1:36 PM

Page 2

www.it-ebooks.info


05_258248 ch01.qxp

3/28/08

1:36 PM

Page 3

Getting Started with
Flash and PHP

T

he process of getting started includes the installation and configuration of Apache, MySQL, and PHP. The examples in this book assume
the installation will be done locally; however, you can modify the
paths and URLs if you want to use a remote server.


IN THIS CHAPTER
Apache installation
PHP installation

The order in which you install these programs is important because they use
paths and variables from each other, which results in the complete development environment.
This installation guide covers Windows and UNIX systems. If you have
decided to work from the book on an existing server, you can skip to
Chapter 2. However, there is some security and configuration information
within this chapter you may find useful.

Adding Apache to a Web Server
The first step to working with Flash and PHP is to install the necessary components. The installation process is defined by installing Apache, then
MySQL, and finally PHP. This order is required because PHP needs paths to
Apache and MySQL in order to provide that support.
You can recompile (build) any one of these components in the future.
However, if you follow this installation order it will mean less work and
rework in the future.
The components to be installed change from time to time, but the overall
installation process remains fairly constant. This means you can download

3
www.it-ebooks.info

MySQL installation


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×