Question
external actionscripts question
How do I change and combine the following .as file and .fla
file into a single .fla....i've tried various ways but none of them
seem to work....any help will be appriciated.
I have a listbox movie clip with an instance name of people_lb in the .fla and the movie clips name is SimpleChat as well as this code.
// a random username
var username = "user_" + getTimer();
// simplechat is a MovieClip on stage and is linked to the SimpleChat class
simplechat.connect("rtmp:/simplechat", username);
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
The following code is the external action script(.as).....
import mx.utils.Delegate;
import mx.controls.List;
class SimpleChat extends MovieClip
{
private var people_lb:List;
public var _username:String; // passed in to the connect method
private var _nc:NetConnection;
private var _chatSO:SharedObject;
// sets up the NetConnection
public function connect( rtmpString:String, username:String )
{
// let's save a reference to the username
_username = username;
_nc = new NetConnection();
_nc.owner = this;
_nc.onStatus = function ( info )
{
//trace(info.code);
if(info.code == "NetConnection.Connect.Success")
{
trace("connected successfully");
// now we can hook up the SharedObject
this.owner.connectSO( this );
}
}
// let's connect
_nc.connect(rtmpString, _username);
}
private function connectSO( nc )
{
// get a reference to a non-persistent remote SharedObject called 'chat_so'
_chatSO = SharedObject.getRemote("chat_so", nc.uri, false);
// Delegate the SharedObject onSync to onChatSOSync
_chatSO.onSync = Delegate.create(this, onChatSOSync);
// connect the SharedObject - often gets forgotten but rather important 😉
_chatSO.connect( nc );
}
private function onChatSOSync ( list )
{
// clear the peoplelist
people_lb.removeAll();
// iterate over all the data 'slots' in the SharedObject
for (var i in _chatSO.data)
{
if (_chatSO.data != null)
{
// this is the client object as stored by the server within application.onConnect
var clientObj = _chatSO.data;
// add each user
people_lb.addItem({label:clientObj.username, data:clientObj});
}
}
};
} // class ends
I have a listbox movie clip with an instance name of people_lb in the .fla and the movie clips name is SimpleChat as well as this code.
// a random username
var username = "user_" + getTimer();
// simplechat is a MovieClip on stage and is linked to the SimpleChat class
simplechat.connect("rtmp:/simplechat", username);
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
The following code is the external action script(.as).....
import mx.utils.Delegate;
import mx.controls.List;
class SimpleChat extends MovieClip
{
private var people_lb:List;
public var _username:String; // passed in to the connect method
private var _nc:NetConnection;
private var _chatSO:SharedObject;
// sets up the NetConnection
public function connect( rtmpString:String, username:String )
{
// let's save a reference to the username
_username = username;
_nc = new NetConnection();
_nc.owner = this;
_nc.onStatus = function ( info )
{
//trace(info.code);
if(info.code == "NetConnection.Connect.Success")
{
trace("connected successfully");
// now we can hook up the SharedObject
this.owner.connectSO( this );
}
}
// let's connect
_nc.connect(rtmpString, _username);
}
private function connectSO( nc )
{
// get a reference to a non-persistent remote SharedObject called 'chat_so'
_chatSO = SharedObject.getRemote("chat_so", nc.uri, false);
// Delegate the SharedObject onSync to onChatSOSync
_chatSO.onSync = Delegate.create(this, onChatSOSync);
// connect the SharedObject - often gets forgotten but rather important 😉
_chatSO.connect( nc );
}
private function onChatSOSync ( list )
{
// clear the peoplelist
people_lb.removeAll();
// iterate over all the data 'slots' in the SharedObject
for (var i in _chatSO.data)
{
if (_chatSO.data != null)
{
// this is the client object as stored by the server within application.onConnect
var clientObj = _chatSO.data;
// add each user
people_lb.addItem({label:clientObj.username, data:clientObj});
}
}
};
} // class ends
