Book Image

Flash Multiplayer Virtual Worlds

Book Image

Flash Multiplayer Virtual Worlds

Overview of this book

Flash virtual worlds are some of the most exciting—and profitable—online business being built today. Using Flash, developers can build interactive environments where users can interact with the virtual world and one another, compete, and have fun. Creating a playful environment on an electronic network presents unique challenges as you combine a fun, upbeat frontend with some serious and complex server logic. This handy book assists you in building amazing virtual worlds in no time by implementing ActionScripts in a Flash IDE. With this book in hand, you will build virtual worlds that have avatars walking around and interacting with non playing characters, completing challenging quests, and allowing users to link with real-world friends. The fun begins with first exploring existing virtual world games such as Club Penguin, Mole, Dofus, and World of Warcraft. We will then design our virtual environment. Then we will create avatars and move the avatars in the virtual world. We will add some triggers to add amusement and life to the virtual world. We will allow the avatars to interact with other players and create a buddy list for each user. Then we will integrate buildings and other environment to the virtual world. We will also let the players interact with non-player characters to complete some tasks. Finally, we move on to add interesting quests to the virtual world, which need to be accomplished by the player to gear up to the next level of the game. This example-rich, hands-on guide sequentially develops a multiplayer virtual world—the platform, the environment, quests, avatars, non-playing characters, and interaction between them.
Table of Contents (18 chapters)
Flash Multiplayer Virtual Worlds
Credits
About the Author
About the Reviewers
Preface

Preface

Back in the late 1970s, digital virtual world and multiuser adventure games, MUDs, made their debut. At the time Internet reached the masses and got popular in 1990s, Massively Multiplayer Online Games, MMOGs, became the new market that every game company was eager to get into. Players download or buy discs to install the online virtual world. The world gives players a virtual personality and they can play and interact with each other to finish tasks.

Being a multimedia and interaction platform, Adobe Flash introduced socket connection support to Flash player. The socket connection allows Flash player to connect persistently to a socket server and provide the opportunity for multiple user Flash applications. In other words, socket connection makes it possible to create a Flash online virtual world.

Compared to the traditional multiplayer online games, Flash online virtual worlds are browser-based and do not need any installation (except the Flash player plugin). They allow players to quickly play the virtual world game just like browsing a web page. The convenience fits the nature of Internet and thus can reach a larger variety of potential players.

Thanks to the quick evolution of socket networking service during these years, Flash online virtual worlds are becoming a trend. Every day users log into social networking sites and play with friends on their virtual farms or virtual towns.

With this book, we will have a step-by-step guide to create our own Flash virtual world from scratch. We will discuss several essential parts of creating a Flash virtual world and integrating it into social networking services. At last, we will have a look on how to deploy and operate our virtual world in production and earn money from it.

What this book covers

Chapter 1, Developing Flash Virtual World, discusses the benefit of developing a Flash virtual world. It also discusses different connection methods between Flash clients and compares different server solutions. You will also get introduced to the common features in a Flash virtual world such as avatar, home, items, quests, non-player characters, and others. You will also know about some existing virtual world games such as Club Penguin, Mole, Dofus, and World of Warcraft.

Chapter 2, Installing The Servers, develops and deploys a virtual world environment. You will also install the Java Development Kit and SmartFoxServer, connect it with MySQL server and configure the server settings. You will then load a simple chat application and set up and log in to the administration panel.

Chapter 3, Getting Familiar with SmartFoxServer, configures a Basic SmartFoxServer and discusses how to set up the Flash player to view the Flash trace log without the Flash IDE. You will also see how we can prevent the Flash loading data or connect sockets to other resources that are not in the same domain of the hosting server by using the Flash player's inbuilt security sandbox. You will also create a Flash document to connect the server and finally, create a whiteboard that every connected user can draw on and test it.

Chapter 4, Creating Map and Ground in Isometric View, compares different game views, create an isometric map, and a ground for the virtual worlds. You will then build a Map Editor, which will be used later for development.

Chapter 5, Creating Avatars, designs an avatar and draws the avatar in Flash. You will then customize your avatar with different styles and colors. You will also design and create a customization panel and finally, integrate it to the SmartFoxServer.

Chapter 6, Walking Around the World, covers the different methods to move the avatar in the virtual world. You will code your first server-side extension and create the connectivity between Flash client and the database.

Chapter 7, Creating Buildings and Environments in the Virtual World, teaches you how to place a building on the Map and order the buildings while displaying them. You will also create a map editor for the buildings.

Chapter 8, Creating an Inventory System, classifies items in the virtual world and also discusses about avatars collecting items. You will also learn about defining the data structure of an inventory item and implementing an inventory and an item panel.

Chapter 9, Communicating with Other Players, discusses the various methods for communicating in the virtual world which includes chatting with public messages. You will also learn how to implement a buddy list, add players to it, and finally send messages to these players. You will also see how we can share items between players.

Chapter 10, Interacting With NPC, shows how we can run a virtual world smoothly by introducing non-player characters. You will place your first NPC and control its movements. You will see the different communication methods available for the NPC and how to trade items with the NPC.

Chapter 11, Designing Quests, introduces quests and how they can be triggered in a virtual world. You will set up server environments for quests and design quest panels. You will also see how you can encourage players to participate in quests by placing rewards and improving the quests.

Chapter 12, Social Community, discusses the benefits of having a social networking feature in your virtual world. This chapter will show you how to integrate with the Facebook and the Twitter platforms.

Chapter 13, Deploying and Maintaining Flash Virtual World, shows how you can host the virtual world and operate the virtual world. You will also see some methods to earn money from virtual world. You will also learn to transfer your virtual world to mobile and other platforms such as Apple iOS and .NET and Unity, among others.

What you need for this book

The software that are required for this book are SmartFoxServerPro_1.6.6, Adobe Flash CS4, and MySQL 5.1.

Who this book is for

If you are a Flash or an ActionScript developer who wants to build powerful and immersive multiplayer games, this book is for you. This book assumes that you have some experience with ActionScript 3.0.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: " We have an npcLoop function in server-side extension."

A block of code will be set as follows:

var javaExt = Packages.it.gotoandplay.smartfoxserver.extensions.ExtensionHelper;
var helper = javaExt.instance();
var zone = helper.getZone("virtualWorld");

When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be shown in bold:

res.list = [];
var holder = param.holder;
var sql = "SELECT * FROM quests WHERE holder='" + holder + "'";
var resultCount = getResultArray(sql, res.list);

Any command-line input or output is written as follows:

javac -version

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "If it prompts for login, click on Skip this Step to bypass it."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book — what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an e-mail to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Note

Downloading the example code for this book

You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books — maybe a mistake in text or code — we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.