# Developing applications using Flex and the Wowza Pro server

**URL:** <https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35>\
**Category:** Wowza Streaming Engine\
**Created:** [May 31, 2007, 12:32pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35 "2007-05-31T12:32:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/system/32/447_2.png) [@system](https://community.wowza.com/u/system)\
**Post date:** [May 31, 2007, 12:32pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/1 "2007-05-31T12:32:24Z")

</div>

To develop client side applications that work with the Wowza Pro server you must set the objectEncoding parameter to ObjectEncoding.AMF0 on the NetConnection2 object before connecting to the Wowza Pro server.

The Flex client side code looks like this:

```auto
var wowzaURL:String = "rtmp://localhost/myapplication";
wowza_conn = new NetConnection2();
wowza_conn.objectEncoding = ObjectEncoding.AMF0; 
wowza_conn.connect(wowzaURL);

```

Charlie

---

<div class="post-metadata">

**Author:** ![leif\_friele](https://avatars.discourse-cdn.com/v4/letter/l/848f3c/32.png) [@leif\_friele](https://community.wowza.com/u/leif_friele)\
**Post date:** [June 8, 2007, 9:12am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/2 "2007-06-08T09:12:53Z")

</div>

the NetConnection2 class is that a class which extends NetConnection and has some added methods which Wowza requires?

We’re trying to migrate from FMS to Wowza, but I get an error when I try streaming audio saying:

AsyncErrorEvent type=“asyncError” bubbles=false cancelable=false eventPhase=2 text=“Error #2095: flash.net.NetStream was unable to invoke callback onMetaData.” error=ReferenceError: Error #1069: Property onMetaData not found on xxxx

---

<div class="post-metadata">

**Author:** ![Trevor\_Smith](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@Trevor\_Smith](https://community.wowza.com/u/Trevor_Smith)\
**Post date:** [February 25, 2008, 12:46pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/3 "2008-02-25T12:46:07Z")

</div>

Here’s a complete mxml file for a simple app. It will run against the VideoChat example included with the Wowza server, though it only uses the audio channels.

\<?xml version="1.0" encoding="utf-8"?\>

\<mx:Application creationComplete=“initAudio()” backgroundGradientColors="[0xFFFFFF,0xFFFFFF]" xmlns:mx=“[http://www.adobe.com/2006/mxml](http://www.adobe.com/2006/mxml)”

horizontalAlign=“center” verticalGap=“5” horizontalGap=“5” width=“215” height=“140” layout=“vertical” verticalAlign=“top”\>

mx:Script

\</mx:Script\>

\<mx:Button enabled=“false” id=“pushToTalkButton” label=“Push to Talk” mouseOut=“stopTalk()” mouseUp=“stopTalk()” mouseDown=“startTalk()”/\>

\<mx:CheckBox enabled=“false” id=“muteCheckBox” label=“Mute” click=“onMuteChange()”/\>

\<mx:Label text=“Loading…” id=“statusLabel”/\>

\</mx:Application\>

---

<div class="post-metadata">

**Author:** ![Ramesh\_Manian](https://avatars.discourse-cdn.com/v4/letter/r/cab0a1/32.png) [@Ramesh\_Manian](https://community.wowza.com/u/Ramesh_Manian)\
**Post date:** [March 10, 2010, 1:28pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/4 "2010-03-10T13:28:44Z")

</div>

Hi Charlie, at the beginnign of this you had talked about NetConnection2 being used by Wowza and seemed to suggest that Flex clients use that. Can you please tell me what Wowza uses NetConnection2 for and is it better that I use that instead of NetConnection? Thanks

---

<div class="post-metadata">

**Author:** ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)\
**Post date:** [June 8, 2007, 6:56am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/5 "2007-06-08T06:56:03Z")

</div>

I don’t know Flex2 but from the error message it looks like you need to add the onMetaData handler to your NetStream object. In Flash you do something like…

```auto
var ns:NetStream = new NetStream(nc);
ns.onMetaData = function(infoObj)
{
     trace("onMetaData: "+infoObj);
};

```

I found this link:

[http://osflash.org/pipermail/osflash\_osflash.org/2006-June/009196.html](http://osflash.org/pipermail/osflash_osflash.org/2006-June/009196.html)

That says for Flex2 the syntax is something like:

```auto
// in your init method
ns.onMetaData = Delegate.create(this, onMetaDataHandler);
// then define the onMetaDataHandler
public function onMetaDataHandler(obj:Object):Void
{
}

```

Let me know if this helps.

Charlie

---

<div class="post-metadata">

**Author:** ![Charlie\_Good](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/charlie_good/32/383_2.png) [@Charlie\_Good](https://community.wowza.com/u/Charlie_Good)\
**Post date:** [March 10, 2010, 1:59pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/6 "2010-03-10T13:59:33Z")

</div>

I do not know of any NetConnection2. I must have mis-typed.

Charlie

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [December 30, 2007, 1:04pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/7 "2007-12-30T13:04:02Z")

</div>

Try this

```auto
public function connect():void
{
nc = new NetConnection();
var client:Object = new Object();					
client.onMetaData = onMetaData;				
client.onBWDone = onBWDone;					
nc.client = client;
nc.objectEncoding = ObjectEncoding.AMF0;
nc.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
}
private function onMetaData():void
{
trace("onMetaData");
}
private function onBWDone():void
{
trace("onBWDone");
}

```

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 15, 2009, 11:20am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/8 "2009-10-15T11:20:48Z")

</div>

You might have to add the Module to the Modules list in your Application.xml

> bwcheck
> 
> Bandwidth Checker
> 
> com.wowza.wms.plugin.bwcheck.ModuleBWCheck2

Put it last, below the other Modules.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 15, 2009, 11:22am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/9 "2009-10-15T11:22:21Z")

</div>

btw, this line is obsolete. You do not need it, and should remove it:

> nc.objectEncoding = ObjectEncoding.AMF0;

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 15, 2009, 11:43am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/10 "2009-10-15T11:43:33Z")

</div>

Try this version:

```auto
var bw:String = "";
public function onBWDone(... rest):void {
	if (rest.length > 0) 
	{
	bw = rest[0];
	trace(rest[0]);
	}
};

```

Richard

---

<div class="post-metadata">

**Author:** ![Maarten\_Dewaele](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Maarten\_Dewaele](https://community.wowza.com/u/Maarten_Dewaele)\
**Post date:** [October 15, 2009, 11:50am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/11 "2009-10-15T11:50:50Z")

</div>

> Try this
> 
> ```auto
> public function connect():void
> {
> nc = new NetConnection();
> var client:Object = new Object();					
> client.onMetaData = onMetaData;				
> client.onBWDone = onBWDone;					
> nc.client = client;
> nc.objectEncoding = ObjectEncoding.AMF0;
> nc.addEventListener( NetStatusEvent.NET_STATUS, netStatusHandler );
> }
> private function onMetaData():void
> {
> trace("onMetaData");
> }
> private function onBWDone():void
> {
> trace("onBWDone");
> }
> 
> ```

Hi,

I’m trying your code. But the onBWDone method is never triggered.

What may be the cause?

The netStatusEvent returns: NetConnection.Connection.Success.

I’m using Flex3 and Wowza Pro10

Thanks

---

<div class="post-metadata">

**Author:** ![Maarten\_Dewaele](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Maarten\_Dewaele](https://community.wowza.com/u/Maarten_Dewaele)\
**Post date:** [October 15, 2009, 12:34pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/12 "2009-10-15T12:34:50Z")

</div>

Ok!

I’m getting into the onBWDone method. But how do I get the detected bandwith and/or other parameters?

function onBWDone(obj:Object) -\> gives error: expected parameter 1, got 0

Thanks a lot already.

Greets

---

<div class="post-metadata">

**Author:** ![Maarten\_Dewaele](https://avatars.discourse-cdn.com/v4/letter/m/22d042/32.png) [@Maarten\_Dewaele](https://community.wowza.com/u/Maarten_Dewaele)\
**Post date:** [October 15, 2009, 2:27pm UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/13 "2009-10-15T14:27:03Z")

</div>

Hi,

I figured it out…

Thanks a lot!

Maarten

---

<div class="post-metadata">

**Author:** ![Shon\_Yarovitsky](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@Shon\_Yarovitsky](https://community.wowza.com/u/Shon_Yarovitsky)\
**Post date:** [March 10, 2010, 8:12am UTC](https://community.wowza.com/t/developing-applications-using-flex-and-the-wowza-pro-server/35/14 "2010-03-10T08:12:06Z")

</div>

Hi. tell me, please, is there a way to force wowza use AMF3 in iclient.call() manually?
