2012-09-12 77 views
1

我有投入數據生成模式下正常......一切工作正常,我也得到將onSeekPoint()事件時,我像做以下一個NetStream:將onSeekPoint古怪

例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回調做......這件事情是這樣的:

例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; 
} 

我想,也許有一些小問題,我missed-但真正嚇到我了,是這完全正常工作......

例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 
} 

我想「如果它沒有壞掉不解決它」可能適用於這裏,但我有點擔心讓一些代碼我不明白去,並且害怕它可能會回來咬我時,我最不希望的它;)

我的問題是:

  1. 爲什麼不seekPoints第二個例子中的工作?
  2. 那好吧,爲什麼確實第二個例子適用於metaData?
  3. 爲什麼第三個示例修復了一切?

編輯:如果現在還不清楚,不同類是正確的在不同的文件,等他們只是組合在這裏的例子,使其更容易消化

回答

0

在第二個例子中,你有這樣的:

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

但它不應該是這樣的:

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

D'o酒店H!!!!!!!!!!! – davidkomer