onSeekPoint weirdness

牧云@^-^@ 提交于 2019-12-24 14:53:09

问题


I have a NetStream which is put into data generation mode properly... everything works fine and I get onSeekPoint() events when I do something like the following:

EXAMPLE 1

public function setupStream() {
     netStream.client = {};
     netStream.client.onSeekPoint = this.onSeekPoint;
     netStream.client.onMetaData = this.onMetaData;
}

public function onSeekPoint(... args) {...}
public function onMetaData(... args) {...}

However, instead of keeping it all in that parent class, I need to create a new class for the client which also has that onSeekPoint. It doesn't work. Strangely, the onMetaData callback does... it's something like this:

EXAMPLE 2

package {
   public class CustomClient {
       public function CustomClient() {
       }
       public function onSeekPoint(... args) {...}
       public function onMetaData(... args) {...}
   }
}

public function setupStream() {
   var myClient:CustomClient = new CustomClient();
   netStream.client = CustomClient;
}

I thought that maybe there's some small issue I missed- but what's really freaking me out, is that this fully works properly...

EXAMPLE 3

package {
   public class CustomClient {
       public function CustomClient() {
       }
       public function onSeekPoint(... args) {...}
       public function onMetaData(... args) {...}
   }
}

public function setupStream() {
   var myClient:CustomClient = new CustomClient();
   netStream.client = {};
   netStream.client.onSeekPoint = myClient.onSeekPoint;
   netStream.client.onMetaData = myClient.onMetaData
}

I guess "if it ain't broke don't fix it" might apply here, but I'm a little worried letting some code I don't understand go, and afraid it might come back to bite me when I least expect it ;)

My questions are:

  1. Why doesn't the second example work for seekPoints?
  2. Ok then- why does the second example work for metaData?
  3. Why does the third example fix everything?

EDIT: In case it's unclear, the different classes are correctly in separate files, etc. They're just combined in the examples here to make it easier to digest


回答1:


In your second example you have this:

var myClient:CustomClient = new CustomClient();
netStream.client = CustomClient;

But shouldn't it be something like this:

var myClient:CustomClient = new CustomClient();
netStream.client = myClient;


来源:https://stackoverflow.com/questions/12393952/onseekpoint-weirdness

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!