Chapter 8. DATA PERSISTENCE WITH FLASH, JSCRIPT, AND HTTP COOKIES


by Christian Cantrell

graphics/01icon08.gif

graphics/01icon04.gif

TOPICS COVERED IN THIS CHAPTER:

  • What are HTTP cookies?

  • Passing JScript data to Flash

  • Using JScript to retrieve cookie data

  • Passing Flash data back to JScript

  • Dissecting FlashTone

  • Using JScript to write to the browser's cookie database

Macromedia Flash is one of the most advanced technologies that is available for user interface design and client-side scripting. It is also becoming an increasingly important component in large-scale, multitier application development as each version of Flash provides better and more sophisticated support for back-end integration. But what if your application falls somewhere in the middle? What if you need to be able to quickly store and retrieve relatively small amounts of information and have them persist from one session to the next, but don't want all the complexity and overhead of integrating a back-end server and database? What if you want your application to run locally, without requiring a network connection? Perhaps you just want to be able to save a few high scores, or store a few simple user preferences. Where you might write out a text file in other languages, or serialize a few simple objects and save them to disk, Flash, combined with JScript (the Pocket Internet Explorer version of JavaScript), can store and retrieve data on client devices using HTTP cookies.

To illustrate the concept of using the browser's cookie database to save data on behalf of a Flash application, we are going to explore FlashTone. FlashTone is a relatively simple and small Flash application I wrote which, by playing tones of the exact same frequency as those generated by touchtone phones, can actually dial numbers for you when you play the tones on your mobile device into the receiver of any touchtone phone. What's interesting about FlashTone, however, is the fact that it also allows users to store up to 10 frequently dialed numbers using nothing but Flash, JScript, and cookies.



Macromedia Flash Enabled. Flash Design and Development for Devices
Macromedia Flash Enabled. Flash Design and Development for Devices
ISBN: 735711771
EAN: N/A
Year: 2002
Pages: 178

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net