问题描述
我有一个正确进入数据生成模式的 NetStream...一切正常,当我执行以下操作时,我会收到 onSeekPoint() 事件:
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:
示例 1
public function setupStream() {
netStream.client = {};
netStream.client.onSeekPoint = this.onSeekPoint;
netStream.client.onMetaData = this.onMetaData;
}
public function onSeekPoint(... args) {...}
public function onMetaData(... args) {...}
然而,我需要为客户端创建一个新类,而不是将其全部保留在该父类中,该类也具有该 onSeekPoint.它不起作用.奇怪的是,onMetaData 回调确实……是这样的:
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:
示例 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...
示例 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 ;)
我的问题是:
- 为什么第二个示例不适用于 seekPoints?
- 好的 - 为什么 第二个示例适用于元数据?
- 为什么第三个示例可以解决所有问题?
- Why doesn't the second example work for seekPoints?
- Ok then- why does the second example work for metaData?
- 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
推荐答案
在你的第二个例子中,你有这个:
In your second example you have this:
var myClient:CustomClient = new CustomClient();
netStream.client = CustomClient;
但不应该是这样的:
var myClient:CustomClient = new CustomClient();
netStream.client = myClient;
这篇关于onSeekPoint 怪异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!