Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Creative tools for business
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 snake and ladder 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

15 November 2010

Page tools

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

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

  • snake_ladder.zip

You can create multiuser games using a Flex component included in the Adobe Connect Collaboration Builder SDK to synchronize SWF files that are loaded into Share pods in Adobe Connect Meeting rooms.  When a SWF is uploaded to a Meeting room, each user in the room receives an instance of the SWF. Using the synchronization capabilities of the Collaboration Builder SDK these applications can communicate with one another, which enables a number of interesting use cases including multiuser games.

This article describes Snakes and Ladders, a simple multiuser game built using the Collaboration Builder SDK.

Game overview

Meeting attendees use SnakeLadder.swf to play the Snakes and Ladders game.  Currently, the game is limited to two players, so any meeting participants not selected to play will not be involved in the game.

After the SWF is loaded into a Share pod in an Adobe Connect Meeting room, the host selects player 1 and player 2 from the available meeting participants (see Figure 1). 

The host selects meeting participants to play Snakes and Ladders.
Figure 1. The host selects meeting participants to play Snakes and Ladders.

The players take turns by clicking the Roll The Dice button.  The player’s colored marker advances based on the result of the dice roll (see Figure 2).  Landing at the base of a ladder will move the player to the top of the ladder, while landing on the head of the snake will move the player to the tail of the snake. When the marker completes its move, an attendee must click the Play button to enable the next roll. The first player to reaches 100 wins the game. To initiate another game, the host again selects two players.

After rolling a 4, the red player advanced from position 1 to position 5.
Figure 2. After rolling a 4, the red player advanced from position 1 to position 5.

How the game works

Snakes and Ladders was written completely in ActionScript 3, using the Collaboration Builder SDK to synchronize events.

To create an application with the Collaboration Builder SDK, you need to load the SWC files as libraries in Flash Builder and add them to the application. The Snakes and Ladders game uses SyncConnector.swc—a Flex component that enables synchronization of multiple SWF files.

To access the API from your application, you need a SyncConnector instance; for example:

<components:SyncConnector id="syncConnector"/>

On creationComplete, you’ll want to add event listeners for the CAUGHT_UP and SYNC_MSG_RCVD events; for example:

syncConnector.addEventListener(SyncSwfEvent.CAUGHT_UP, caughtUpHandler ); syncConnector.addEventListener(SyncSwfEvent.SYNC_MSG_RCVD, syncMsgRcvdHandler );

Any application that use the SyncConnector component goes through a catch-up phase as it is loaded into a Share pod. The catch-up phase allows new participants to receive the accumulated state of the application. After all messages are received, SyncConnector dispatches a CAUGHT_UP event.

In the CAUGHT_UP event handler you can perform any operations that are required immediately after the SWF loads (as long as they do not need to dispatch any sync messages).

For example, the Snakes and Ladders game populates the list controls with all the meeting participants in the CAUGHT_UP event handler. The application has the following ComboBox control:

<mx:ComboBox x="205" y="152" id="comboBoxName" labelField="fullName" />

To populate the control it retrieves the list of users into an array using syncConnector.userList, and sets the array as the control’s data provider:

Var list:Array = syncConnector.userList; comboBoxName.dataProvider=list;

In the syncMsgRcvdHandler method you need to check for any events received.  In Snakes and Ladders, this method checks for messages that indicate a new roll of the dice.  When the client is notified of a new roll, it updates the display with the roll value and initiates to move the markers:

if (evt.data.msgNm=="diceValue") { diceVal.text=evtData.msgVal as String; initiate(); }

By default, only the host (not meeting participants) can call the dispatchSyncMessage() method to dispatch messages through Adobe Connect.

In Snakes and Ladders the diceValue message is dispatched using the following code:

syncConnector.dispatchSyncMessage("diceValue",diceVal.text,false);

The host can call the SyncConnector.allowParticipantPublish() method to allow participants to publish a specified message; for example:

syncConnector.allowParticipantPublish("diceValue", true);

To restrict access to the Roll The Dice button, Snakes and Ladders uses the click event to check if the username of the particular client is same as the username of the player whose turn it is to roll the dice.  In the application, the names of the two players are stored in variables that are synchronized across all clients.  The Roll The Dice click handler checks the usernames using the following code:

private function rollingDice(evt:MouseEvent):void { If(syncConnector.userName == player1) …}

The application uses an easing effect to smooth the movement of the marker. The head and tail coordinates of the snakes and ladders are stored in an array. After each roll of the dice, the code checks the marker’s position against the values in these arrays. If the marker has landed on a snake head it descends to the tail, and if it has landed at the base of a ladder it climbs to the top.

Where to go from here

Currently Snakes and Ladders is a two-player game, but it is possible to create breakout rooms to enable more attendees to play. I’m planning a multiplayer version of the game in which any number of attendees can play.

For more information, including details on how to test an application in Flash Builder without Adobe Connect, see Using the Adobe Connect Collaboration Builder SDK 2.0 .

You can download the Adobe Connect Collaboration Builder SDK from the Adobe Connect Developer Center.

More Like This

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

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