Devam Ediyor

520577 weekone

Week 1: Multiplayer Games and SmartFoxServer Configuration - iLab

Print This Page

Note: There are two lab assignments due this week.

iLab 1 of 8: Establishing a Connection

iLab 2 of 8: Creating a Login Screen

Remember this!

Connect to the iLab here.

iLab 1 of 8: Establishing a Connection

Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.

(See Syllabus/"Due Dates for Assignments & Exams" for due dates.)

i L A B O V E R V I E W

Scenario/Summary

Students will develop a simple module that will establish a connection with a local or remote SmartFoxServer.

Deliverables

Students must deliver a .fla file containing all the source code; source code must be in the correct location specified by the lab steps.

i L A B S T E P S

SETUP

Follow the instructions in Creating Saving and Testing Labs, under Section A: Creating a Flash Actionscript.

STEP 1: Creating a class path to the SmartFoxServer Client API

Create a new Flash project, AS3, and create a class path to the SmartFoxServer Client API.

Hint: You should navigate to the following screen:

STEP 2: Importing the appropriate classes

Open up the Actionscript panel – make sure you're on the first frame when doing this.

Type in the ONE line of code that will import the SmartFoxServer classes.

Hint: If you typed in the code correctly, and followed Step 1 correctly, you should be able to add the following line of code and compile without errors:

// Code that imports SmartFoxServer classes should go here

var smartfox:SmartFoxClient = new SmartFoxClient();

If the Flash environment outputs errors when you try to run the movie, go back and make sure you did step 1 correctly and that you typed in the correct line that imports the SmartFoxServer classes for step 2. After the program compiles without errors, make sure to remove the line of code shown above.

STEP 3: Setting up a connection

Make sure that the following code is all in the first frame, the same frame in which you type the code outline in step 2.

Call the Stop function so the playhead doesn't move.

Create and initialize the properties and objects that will be used to connect to the server, and handle a server connection – this is explained in the following steps.

Create a variable of type string, name it "ip", and assign it the IP address of the server you will attempt to connect to. Remember that you will be connecting to a local computer, so this IP address should reference the IP number which is associated with "local host".

Create a variable of type int, name it "port", and assign it the port number the server connection will be made on.

Create and instantiate a SmartFoxClient object; name it "smartfox".

Make sure that the connection doesn't attempt a bluebox connection if our default connection fails.

Add an event listener to the SmartFoxClient object, which you created in part 6 of this step, that will listen for the [url removed, login to view] event. Name the event listener "onConnected".

STEP 4: Connecting to the server

Type in the ONE line of code that will connect you to the server.

Hint: The line of code consists of a function call on the SmartFoxClient object created in step 3, in which you pass in your IP and Port number as parameters.

STEP 5: Handling a successful and unsuccessful server connection

Create the event handler function that you assigned to listen for the [url removed, login to view] event in Step 3 – remember it's called "onConnected". Implement it so that if the connection to the server is successful, the application displays "Success :)" in the middle of the screen. If the connection is unsuccessful, then it should display "Failure :(". In order to display "Success :)" and "Failure :)" you will have to create a dynamic textfield in the middle of the canvas and change it appropriately depending on the results.

Hint: Remember that all event handlers that listen for a SFSEvent must include a parameter of type SFSEvent by default.

STEP 6: Testing the lab

Follow the instructions in Creating Saving and Testing Labs, under Section B: Testing a Lab.

--------------------------------------------------------------------------------

iLab 2 of 8: Creating a Login Screen

Remember this!

Connect to the iLab here.

Submit your assignment to the Dropbox located on the silver tab at the top of this page. For instructions on how to use the Dropbox, read these Step-by-Step Instructions or watch this Dropbox Tutorial.

(See Syllabus/"Due Dates for Assignments & Exams" for due dates.)

i L A B O V E R V I E W

Scenario/Summary

Students will develop a simple module that displays a login screen for the user.

Deliverables

Students must deliver a .fla file containing all the source code; source code must be in the correct location specified by the lab steps.

i L A B S T E P S

SETUP

Follow the instructions in Creating Saving and Testing Labs, under Section A: Creating a Flash Actionscript.

STEP 1: Exploring the .fla

Open up the lab 2 starter kit; you should see the following on the stage:

The text field that contains the "Connecting…" text is a dynamic textfield that will be used to notify the user of the status of the connection.

The object right underneath the text field is a TextInput component; the user will use this component to input a user name.

The object under the TextInput component is a Button Component; the user will click this in order to login to the server.

The ball to the left of the TextInput component is a movieclip that will act as a connection indicator to the user. Double-click it to view what the movieclip is composed of.

You should see a timeline with 3 distinct keyframe names, as follows:

Click through each keyframe to get an idea of what the movieclip will look like depending on which frame it's on. While on the "attempting" frame it should be gray, on the "success" frame it turns green, and on the "failure" frame it turns red.

Now that you have an outline of what you have to work with, you are ready to proceed to the next step.

STEP 2: Giving objects an instance name

First, let's give everything on the stage an instance name so we can work with the objects via Actionscript.

Call the dynamic text field "connectionStatusTxt", call the TextInput component "textInput", call the Button Component "loginBtn", and call the movieclip "connectionIndicator".

Click on the first frame of the .fla and open up the Actionscript panel – you should see Actionscript code from the first lab.

STEP 3: Modifying the onConnected handler

Modify the implementation of the onConnected handler so that the movieclip connection indicator displays the green graphic when a connection is successful.

Modify the implementation of the onConnected handler so that the movieclip connection indicator displays a red graphic when the connection is a failure.

Modify the implementation of the onConnected handler so that the dynamic textfield displays "Connection Successful!" when the connection is successful.

Modify the implementation of the onConnected handler so that the dynamic textfield displays "Connection Failure!" when the connection is a failure.

Modify the implementation of the onConnected handler so that if there is a successful connection, an event handler is added to the button component that listens for the ComponentEvent.BUTTON_DOWN event – call the event handler "onUserEnterName". Make sure that you import the component event, at the top of the file, via an import statement.

Since we now have a visual way of displaying the status of the server connection, there is no need for the trace statements that were implemented in the first lab. Remove both trace statements in the onConnection implementation.

STEP 4: Implementing the onUserEnterName Handler

Declare the onUserEnterName handler – the following steps outline what implementations should be included in the function.

Add an event listener to the SmartFoxClient object that you instantiated in lab 1. The listener should listen to the onLogin SmartFoxServer event; call the handler "onUserLogin".

Call the "login" function on the SmartFoxClient object that was instantiated in lab 1. You should pass in the zone name "sftris", the text that is in the TextInput component (which corresponds to the user's name), and an empty string for the password.

STEP 5: Implementing the onUserLogin Handler

Declare the onUserLogin handler – the following steps outline what implementation should be included in the function.

Implement an if/else such that if the login was successful, "good login" is printed to the screen, and if the login was unsuccessful, " bad login" is printed to the screen. You will have to create a dynamic Textfield to display these results – place the Textfield underneath the login button.

STEP 6: Testing the lab

Follow the instructions in Creating Saving and Testing Labs, under Section B: Testing a Lab.

Beceriler: ActionScript, Adobe Flash, Her şey Kabul, Oyun Tasarımı, Web Sitesi Yönetimi

Daha fazlasını görün: tutorial top, tutorial games, top tutorial, top change tutorial, syllabus graphic design, step students, silver screen design, remote graphic design work, project handler, printed names, path tutorial, line game design, number tutorial, int v, read computer code, make follow call, made field graphic design, graphic design statement work, graphic design starter kit, graphic design computer program, go tutorial, game tutorial, games tutorial, game stop, follow application

İşveren Hakkında:
( 4 değerlendirme ) fontana,

Proje NO: #2266514

Seçilen:

eperfections

Please see PMB

7 gün içinde 175$ USD
(329 Değerlendirme)
7.1