I’m John C Bland II

Husband, Father, Tech Author, Deacon.
Founder of Katapult Media, and full-stack polyglot developer.
Political Free Agents Podcast Host.

I create. I launch.

YouTube Channel

I post regular fun on YouTube like me playing the bass and anything else I find fun. 

Get Something Built

All project work goes through Katapult Media. Business is open. Let’s chat.

Ok…this one made me work a bit. A customer was having a problem using Flex to build a simple video player. The player I built, at work, is FP9 but AS2 (medium-long story) so I hadn’t come across their specific problem.

The Problem
ReferenceError: Error #1069: Property onBWDone not found on flash.net.NetConnection and there is no default value.

The Problem #2
ReferenceError: Error #1069: Property onFCSubscribe not found on com.llnw.controls.MediaPlayer and there is no default value.

Quick Discussion
Both problems are the same issue. When you call Flash Media Server and attempt to connect there is server-side Actionscript that gets executed. For certain calls there is a return call. For example:

_netConnection.call(“FCSubscribe”, null, “mystreamname”);

With that type of call you will get a return call to onFCSubscribe.

The AS2 Solution
In AS2 it is easy because of how loose classes are. You can easily use:

_netConnection.onFCSubscribe = Delegate.create(this, handleFCSubscribe);

This is exactly what I do and it works but AS2 isn’t the problem here…AS3 is the culprit.

The AS 3 Solution
My first shot at it was an old AS2 “hack”:

NetConnection.prototype.onFCSubscribe = handleFCSubscribe;

That worked just fine but it kind of bugged me. I just felt a little dirty hitting the “.prototype” keystrokes. So, I kept looking.

{insert blaring horns of victory; or Fanfare…whatever your song preference}

public function onFCSubscribe(info:Object):void{
trace(“worked”);
}

public function play(connectionurl:String):void{
_netConnection = new NetConnection();
_netConnection.client = this;
_netConnection.connect(connectionurl);
}

That’s it right there. _netConnection.client = this; is the fix. What it tells the server-side actionscript is “when you want to return calls, return them on my client property.” So, since “client = this” all of the calls from FMS back to my client will run inside of “this”.

{long sigh}

Man…I feel a little cleaner now. 🙂 Well, that fiasco is over so I need to head to the house. Ping me if you have any other questions here.