The following code is a combination of samples taken from red5. Basically I am trying to combine a live stream subscriber with a chat box based on shared objects. I'm not a flash developer and have a very limited understanding of what is going on here.
// ** AUTO-UI IMPORT STATEMENTS **
import org.red5.utils.Connector;
import org.red5.samples.simplechat.BasicChat;
// ** END AUTO-UI IMPORT STATEMENTS **
import com.neoarchaic.ui.Tooltip;
import org.red5.net.Stream;
//import org.red5.utils.Delegate;
import com.blitzagency.xray.util.XrayLoader;
class org.red5.samples.livestream.subscriber.Main extends MovieClip {
// Constants:
public static var CLASS_REF = org.red5.samples.livestream.subscriber.Main;
public static var LINKAGE_ID:String = "org.red5.samples.livestream.subscriber.Main";
// Public Properties:
// Private Properties:
private var stream:Stream;
private var cam:Camera;
// UI Elements:
// ** AUTO-UI ELEMENTS **
private var connector:Connector;
private var publish_video:Video;
private var chat:BasicChat;
// ** END AUTO-UI ELEMENTS **
private var uri:String = "rtmpt://localhost/oflaDemo";
// Initialization:
private function Main() {XrayLoader.loadConnector("xray.swf");}
private function onLoad():Void { configUI(); }
// Public Methods:
// Semi-Private Methods:
// Private Methods:
private function configUI():Void
{
// setup the tooltip defaults
Tooltip.options = {size:10, font:"_sans", corner:0};
// setup cam
cam = Camera.get();
// get notified of connection changes
connector.addEventListener("connectionChange", this);
// set the uri
Connector.red5URI = uri;
// initialize the connector
connector.configUI();
connector.makeConnection();
}
private function connectionChange(evtObj:Object):Void
{
if(evtObj.connected)
{
// setup stream
// XXX: odd hack needed for flashIDE.
var conn = evtObj.connection;
var x = new Stream(conn);
stream = x;
stream.play("red5StreamDemo", -1);
publish_video.attachVideo(stream);
trace(chat);
// register the NetConnection that GlobalObject will need
chat.registerConnection(conn);
// connect the shared object
chat.connectSO();
}
}
}
I don't think that var chat
is being initialized anywhere as trace(chat)
prints 'undefined'. However var connector
and var publish_video
seem to collect their instances from the stage.
This sample code included those two and worked fine, but I can't make my additions behave the same way.
I have added an instance of BasicChat to the stage (I'm using Flash CS4) and have spent the past many hours playing with it's various properties, layers and groupings, but to no avail.
Can anyone suggest why my var chat
isn't collecting its instance from the stage?