i've extended the NetLoader to have access to NetConnection and NetStream. Further i extended NetClient class
and added it as client to NetConnection and NetStream.
NetConnection listeners are working fine. onBWCheck and onBWDone are triggered correctly.
Now i need to add some functionality to onPlayStatus and onMetaData but my client listeners are never called.
my code looks like this:
override protected function createNetStream(connection:NetConnection, resource:URLResource):NetStream
var client:CustomNetClient = new CustomNetClient();
_nc = connection;
_nc.client = client;
_ns = new NetStream(connection);
_ns.client = client;
i tried the it the way i was used to and just added a public function onMetaData to my CustomNetClient class but that did not work.
my next attempt was to try:
but that did not work either.
somebody got an idea / solution for this?
thx in advance
There is a private method in NetLoader.as that creates a new NetClient() that effectively replaces the one you created in your overriden method:
private function finishLoading(connection:NetConnection, loadTrait:LoadTrait, factory:NetConnectionFactoryBase = null):void
var netLoadTrait:NetStreamLoadTrait = loadTrait as NetStreamLoadTrait;
if (netLoadTrait != null)
netLoadTrait.connection = connection;
var netStream:NetStream = createNetStream(connection, netLoadTrait.resource as URLResource);
netStream.client = new NetClient();
netLoadTrait.netStream = netStream;
netLoadTrait.switchManager = createNetStreamSwitchManager(connection, netStream, netLoadTrait.resource as DynamicStreamingResource);
netLoadTrait.netConnectionFactory = factory;
processFinishLoading(loadTrait as NetStreamLoadTrait);
Unfortunately, this is a private method and cannot be overriden. But there is a way to get your custom NetClient into the Netstream.client which involves creating your own constructor and making sure that your CustomNetClient is the last NetClient to be assigned to Netstream.
You'll need to access the NetLoader.as source to know where and when to assign your CustomNetClient.