Adobe 65029121 - Flash Media Streaming Server Developer's Manual page 57

Developer's guide
Hide thumbs Also See for 65029121 - Flash Media Streaming Server:
Table of Contents

Advertisement

Design the user interface
In Adobe Flash CS3 Professional, choose File > New > Flash File (ActionScript 3.0), and click OK.
1
From the toolbox, select the Rectangle tool. Drag to the lower-right corner, then select the Oval tool.
2
Draw a circle on the Stage. Give it any fill color you like.
3
4
Double-click the circle, and choose Modify > Convert to Symbol.
In the Convert to Symbol dialog box, name the symbol ball, check that Movie Clip is selected, and click OK.
5
Select the ball symbol on the Stage, and in the Property Inspector (Window > Properties), give it the instance
6
name sharedBall.
Save the file as SharedBall.fla.
7
Write the client-side code
Be sure to look at the SharedBall.as sample file. These steps present only highlights.
In Flash CS3, create a new ActionScript file.
1
2
Create the class, extending MovieClip:
public class SharedBall extends MovieClip {...}
The class must extend MovieClip, because the sharedBall symbol in the FLA file is a Movie Clip symbol.
Create the constructor, in which you add event listeners and connect to the server:
3
public function SharedBall()
{
nc = new NetConnection();
addEventListeners();
nc.connect("rtmp://localhost/SharedBall");
}
Add event listeners for
4
private function addEventListeners() {
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
// sharedBall is defined in the FLA file
sharedBall.addEventListener(MouseEvent.MOUSE_DOWN, pickup);
sharedBall.addEventListener(MouseEvent.MOUSE_UP, place);
sharedBall.addEventListener(MouseEvent.MOUSE_MOVE, moveIt);
}
In your
handler, create a remote shared object when a connection is successful. (You'll also want to
5
netStatus
create error handlers for rejected and failed connections, shown in the sample AS file.) Connect to the shared object
and add a
event listener:
sync
switch (event.info.code)
{
case "NetConnection.Connect.Success":
trace("Congratulations! you're connected");
so = SharedObject.getRemote("ballPosition", nc.uri, false);
so.connect(nc);
so.addEventListener(SyncEvent.SYNC, syncHandler);
break;
...
}
6
As a user moves the mouse, use
function moveIt( event:MouseEvent ):void {
,
,
netStatus
mouseDown
mouseUp
setProperty()
, and
events:
mouseMove
to set the changing ball location in the remote shared object:
ADOBE FLASH MEDIA SERVER
Developer Guide
54

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash media server

Table of Contents