Groups | Blog | Home
all groups > macromedia flash flashcom > july 2005 >

macromedia flash flashcom : NetStream not streaming


dubya
7/16/2005 9:34:57 AM
hey everybody! :)

the first chapter of the oreilly fcs book has a helloVideo app that works.
it's pretty much what i want to do with my app so i'm learning by taking the
code and pasting it into my own AS2 class MVC framework.

only it's not working therein. i've simplified and simplified but still the
server cannot pick up a basic NetStream. the oreilly code that i have cut down
plus my own is at the bottom of this post. it's more or less identical so i
really can't see how it would fail. but it does.

the server side code is identical btw. its the oreilly code

oreilly netstreams = 1. my netstreams = 0;

any ideas?

code follows:


oreilly code:

myID = "";
nc = new NetConnection();

nc.setID = function(id){
ns = new NetStream(nc);
}

connectButton.addEventListener("click", this);

function click(ev) {
nc.connect("rtmp:/helloVideo", userNameInput.text);
}



my code:

class com.packageName.Model implements IModel {

private var _nc :NetConnection;
etc...

private function onLoginSuccess ():Void
{
connect();
}

private function connect ():Void
{
_nc = new NetConnection();
_nc.setID = function(id) {
var ns = new NetStream( this );
}
_nc.connect( "rtmp:/myApp", _user.name );
}

}


dubya
8/9/2005 1:06:37 PM
hey everybody

it took weeks but i worked this out for myself:

NetStream objects ONLY stream if they are put RIGHT ON THE _ROOT!!!

so i've you're using AS2 classes, you'll need some kind of method that returns
you a ref to the _root object. so maybe this in your overarching Application
class:

public function getContext():MovieClip
{
return _root;
}

and then something like this elsewhere:

public function connect ():Void
{
_nc = new NetConnection();
_nc.setID = function(id) {
Application.getContext().ns = new NetStream( _nc );
_ns = Application.getContext().ns;
}
_nc.connect( "rtmp:/myApp", _user.name );
}

why oh why oh etc. cannot this kind of thing be made clear in MM
documentation?!?!?!?!?!?!?

frustrated of brighton, uk. :|
AddThis Social Bookmark Button