Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / Adobe Connect Developer Center /

Building a multiuser Sudoku contest game using the Adobe Connect Collaboration Builder SDK

by Rajesh Kumar

Rajesh Kumar
  • connectusers.com

Content

  • Game overview
  • How the game works
  • Where to go from here

Created

17 January 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
Adobe Connect collaboration gaming

Requirements

Prerequisite knowledge

Knowledge of ActionScript 3 and Flex is required to make the most of this article.

 


Additional required product:

Adobe Connect Collaboration Builder SDK

User level

Intermediate

Required products

  • Flash Player 10.1
  • Adobe Connect (Download trial)

Sample files

  • multiuser-sudoku.zip (596 KB)

In a previous article, I described a simple multiuser snake and ladder game that I built using the Adobe Connect Collaboration Builder SDK. That article showed you how to synchronize SWF files that are loaded into Share pods in Adobe Connect meeting rooms using a Flex component included in the Adobe Connect Collaboration Builder SDK. This capability makes it easy to build multiuser games in which the SWF applications communicate with one another. In this article, I describe Sudoku Contest, which, unlike the snakes and ladders example, supports more than two players.

Sudoku Contest is a multiplayer game in which each contestant receives the same Sudoku puzzle that is generated by the host. The host has the ability to stop the contest (after a sufficient amount of time has elapsed), broadcast the solution, and end the contest.

Game overview

After uploading the SudokuContest.swf into a Share pod, the host generates a Sudoku puzzle by clicking Generate Sudoku (see Figure 1).

The host clicks Generate Sudoku to start the game.
Figure 1. The host clicks Generate Sudoku to start the game.

The Sudoku puzzle is then presented to all meeting attendees, including the host. Once a user solves and submits the puzzle, the user's name, result, and elapsed time is added to a data grid, which is visible to all attendees. After an attendee has submitted a solution, his Sudoku puzzle panel will be disabled. The host can stop the contest at any time by clicking the Time Up button, which disables each contestant's Sudoku puzzle panel. The host can also broadcast the solution to all contestants.

How the game works

The Sudoku Contest game was written completely in ActionScript 3, making use of the Collaboration Builder SDK to synchronize events.

As with the snakes and ladders game, I loaded SyncConnector.swc—a Flex component that enables synchronization of multiple SWF files—as a library in Flash Builder and added it to the application.

To access the Collaboration Builder SDK API from an application, you need a SyncConnector instance; for example:

<components:SyncConnector id="sudokuConnector"/>

The application uses sudokuConnector, an instance of SyncConnector, to communicate with other application instances.

On creationComplete, the Sudoku Contest application adds event listeners for the CAUGHT_UP and SYNC_MSG_RCVD events:

syncConnector.addEventListener(SyncSwfEvent.CAUGHT_UP,<caughtUpHandler>); syncConnector.addEventListener(SyncSwfEvent.SYNC_MSG_RCVD,<syncMsgRcvd>);

You may recall that every application that uses the SyncConnector component goes through a catch-up phase when it is loaded into a Share pod. This phase allows new attendees to receive the accumulated state of the application. After all messages are received, SyncConnector dispatches a CAUGHT_UP event.

The CAUGHT_UP event handler can perform any operations that are required immediately after the SWF loads (as long as they do not need to dispatch any sync messages). In this application, for example, the handler ensures that any new participant entering the room is shown the current puzzle if a contest has already started.

The SYNC_MSG_RCVD event handler is invoked when events are received. For example, in Sudoku Contest, this event handler is invoked when a new puzzle is generated and sent to the attendees. When the host clicks the button to generate a Sudoku puzzle, the application creates a random puzzle in the form of a 9 × 9 matrix (see Figure 2). This matrix is dispatched to all the attendees using the dispatchSyncMessage API of the Collaboration Builder SDK:

sudokuConn.dispatchSyncMessage("sudokuGenerated", Sudoku, false);

It is received by all the contestants in the SYNC_MSG_RCVD handler, syncMsgRcvd(evt:SyncSwfEvent). For example:

if (evt.data.msgNm=="sudokuGenerated"){ Sudoku=evtData.msgVal as Array; currentState="contest"; ..}
The puzzle is a 9 x 9 matrix. View larger
Figure 2. The puzzle is a 9 x 9 matrix.

Each client uses the matrix received in syncMsgRcvd to create and display the puzzle.

When a contestant completes the puzzle and submits a solution, it is evaluated on the client side and the user's information is added to the DataGrid component, which is also synchronized across all attendees. When the host selects Broadcast Solution, the correct answer will be revealed to all attendees (see Figure 3).

The application uses states to manage the different views. The main screen, for example, is different for the host and participants. The code checks sudokuConn.role and sets the value of currentstate appropriately:

if(sudokuConn.role=="owner") currentState="host"; else currentState="participant";
The host can click Broadcast Solution to reveal the puzzle solution to all attendees. View larger
Figure 3. The host can click Broadcast Solution to reveal the puzzle solution to all attendees.

The data grid displays information on any contestant who has submitted a puzzle solution. Each participant must have permission to publish his or her information before calling dispatchSyncMessage:

dispatchSyncMessage: sudokuConn.allowParticipantPublish("gridObject", true); sudokuConn.dispatchSyncMessage("gridObject", obj, false);

The Flex DataGrid component can be easily sorted by elapsed time to identify the winner. When the host clicks End Contest, the game is over (see Figure 4).

The "Thank you" message is displayed after the host clicks End Contest.
Figure 4. The "Thank you" message is displayed after the host clicks End Contest.

Where to go from here

The current version of Sudoku Contest has just one level of difficulty and supports only 9 × 9 puzzles. One possible enhancement is to allow the host to select easy, medium, and hard puzzles as well as use a bigger matrix.

If you have not already done so, you may want to read my companion article, Building a multiuser snake and ladder game using the Adobe Connect Collaboration Builder SDK.

See Using the Adobe Connect Collaboration Builder SDK 2.0 (PDF, 200 KB) for additional details, including instructions on how to test an application in Flash Builder without Adobe Connect 8.

To download the Adobe Connect Collaboration Builder SDK, visit the Adobe Connect Developer Center.

If you are interested in seeing the current state of the sample files I used when writing this article, send me an e-mail at rakumar@adobe.com.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License

More Like This

  • Creating a custom stamp for Adobe Connect 8
  • Integrating the Asterisk MeetMe audio conferencing service with Adobe Connect 8
  • Building a multiple-question survey application for Adobe Connect 8
  • Building a multiuser snake and ladder game using the Adobe Connect Collaboration Builder SDK
  • Saving data locally in a custom application for Adobe Connect

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement