Skip to main content
Participant
August 29, 2008
Answered

Getting onBWDone kbps from ConnectClient with FMS 3

  • August 29, 2008
  • 2 replies
  • 936 views
I have extended various fl.video classes for my version of FLVPlayback. I call _nc.call("checkBandwidth",null); in aprox. line 1369 of NCManager.as because I could not figure out how else to access the instance of the netConnection. I get the response inside ConnectClient.as onBWDone. It traces out the bandwidth no problem. So now I am trying to get that variable back to my application mediator. I tried a getter inside ConnectClient.as but that throws a null reference error.
Thanks for any suggestions.
Greg
    This topic has been closed for replies.
    Correct answer gregbown
    I made a new custom event that accepts any data type.
    public class RelayEvent extends Event{
    public static const RELAY_EVENT:String = "relayevent";
    public var relay:*;
    public function RelayEvent(type:String, obj:*){
    super(type, bubbles, cancelable);
    this.relay = obj;
    }
    override public function clone():Event {
    return new RelayEvent(this.type, this.relay);
    }
    }
    I then dispatched a new event like so inside NCManager.
    _owner.dispatchEvent(new RelayEvent(RelayEvent.RELAY_EVENT, Event.bandwidth)); I am using the only display object inside NCManager to dispatch the event. I had tried it before but got a unable to convert error. The RelayEvent class can accept any data type so the combination fixed my problem. yay! Thanks.

    2 replies

    gregbownAuthorCorrect answer
    Participant
    September 4, 2008
    I made a new custom event that accepts any data type.
    public class RelayEvent extends Event{
    public static const RELAY_EVENT:String = "relayevent";
    public var relay:*;
    public function RelayEvent(type:String, obj:*){
    super(type, bubbles, cancelable);
    this.relay = obj;
    }
    override public function clone():Event {
    return new RelayEvent(this.type, this.relay);
    }
    }
    I then dispatched a new event like so inside NCManager.
    _owner.dispatchEvent(new RelayEvent(RelayEvent.RELAY_EVENT, Event.bandwidth)); I am using the only display object inside NCManager to dispatch the event. I had tried it before but got a unable to convert error. The RelayEvent class can accept any data type so the combination fixed my problem. yay! Thanks.
    Inspiring
    August 31, 2008
    use a custom event.

    so onBWDone gets called... you dispatch an event from there with the information that you require.
    gregbownAuthor
    Participant
    September 3, 2008
    Thanks, however I am still saddled with the issue of how to get the number back to my application mediator. With the custom event I can relay the number back to the NCManager but no further. According to as3 rules when an object that is not part of the display hierarchy is the event target that target is the sole object notified of the event. Because the netConnection is not a display object the event wont be received by my FLVPlayback unless I can access the netConnection instance. Here is my Custom event, maybe I'm missing something?
    package fl.video{
    import flash.events.Event;
    public class VideoPlayerEvent extends Event{
    public static const VIDEO_PLAYER_EVENT:String = "videoplayerevent";
    public var bandwidth:Number;
    public function VideoPlayerEvent(type:String, ncbw:Number){
    super(type, bubbles, cancelable);
    this.bandwidth = ncbw;
    }
    override public function clone():Event {
    return new VideoPlayerEvent(this.type, this.bandwidth);
    }
    }
    }
    Inside ConnectClient.as
    this.nc.dispatchEvent(new VideoPlayerEvent(VideoPlayerEvent.VIDEO_PLAYER_EVENT, p_bw));
    The event is only received when the listener is added to the netConnection instance inside NCManager. I tried to relay the event from there by dispatching a new event with no luck.
    I'm probably overlooking something simple too an experienced as3 oop.
    Any further suggestions are welcome.
    Thanks
    Greg