# simple actionscript 3 example

**URL:** <https://community.wowza.com/t/simple-actionscript-3-example/324>\
**Category:** Wowza Streaming Engine\
**Created:** [April 4, 2008, 8:08am UTC](https://community.wowza.com/t/simple-actionscript-3-example/324 "2008-04-04T08:08:52Z")\
**Posts on this page:** 3\
**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:** [April 4, 2008, 8:08am UTC](https://community.wowza.com/t/simple-actionscript-3-example/324/1 "2008-04-04T08:08:52Z")

</div>

I recently started using Wowza with a view to setting up an elearning system with streaming video. However I am using actionscript 3 and I am having problems in getting any video to play at all.

Here is my code - just a simple example to do a proof of concept job…

```auto
var customClient:Object = new Object();
customClient.onCuePoint = cuePointHandler;
customClient.onMetaData = metaDataHandler;
var nc:NetConnection = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0; 
nc.connect("rtmp://localhost:1935/simplevideostreaming");
nc.addEventListener(NetStatusEvent.NET_STATUS, statushandler);
var ns:NetStream;
var video:Video = new Video();
video.attachNetStream(ns);
function statushandler(e:NetStatusEvent):void
{
	//trace(e);
	if (e.info.code == "NetConnection.Connect.Success")
	{
		trace(e.info.code);
		
		ns = new NetStream(nc);
		ns.client = customClient;
		addChild(video);
 		ns.play("Extremists");
		
	}
}
function cuePointHandler(infoObject:Object):void 
{
    trace("cuePoint");
}
function metaDataHandler(infoObject:Object):void 
{
    trace("metaData");
}

```

I have looked through the forums and one of the issues was handling the metadata, and so i added the extra Object, but all that happens is my output tells me that i have successfully connected, but i see no video at all.

Does anyone have any ideas what i am doing wrong?

btw the server does work as i have used the supplied simple example (as2) and the video is served up.

Any help would be greatly appreciated.

---

<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:** [April 4, 2008, 3:41am UTC](https://community.wowza.com/t/simple-actionscript-3-example/324/2 "2008-04-04T03:41:16Z")

</div>

I modified your code and it works for me:

```auto
var customClient:Object = new Object();
customClient.onCuePoint = cuePointHandler;
customClient.onMetaData = metaDataHandler;
var nc:NetConnection = new NetConnection();
nc.objectEncoding = ObjectEncoding.AMF0; 
nc.connect("rtmp://localhost:1935/simplevideostreaming");
nc.addEventListener(NetStatusEvent.NET_STATUS, statushandler);
var ns:NetStream;
var video:Video = new Video();
function statushandler(e:NetStatusEvent):void
{
	trace(e);
	if (e.info.code == "NetConnection.Connect.Success")
	{
		trace(e.info.code);
		
		ns = new NetStream(nc);
		ns.client = customClient;
		video.attachNetStream(ns); <-- move this to here
		addChild(video);
 		ns.play("Extremists");
		
	}
}
function cuePointHandler(infoObject:Object):void 
{
    trace("cuePoint");
}
function metaDataHandler(infoObject:Object):void 
{
    trace("metaData");
}

```

Charlie

---

<div class="post-metadata">

**Author:** ![Alex\_Silver](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Alex\_Silver](https://community.wowza.com/u/Alex_Silver)\
**Post date:** [April 4, 2008, 12:13pm UTC](https://community.wowza.com/t/simple-actionscript-3-example/324/3 "2008-04-04T12:13:54Z")

</div>

much appreciated charlie - works perfectly - i did not realise that the attachNetStream was so picky in its placement 🙂
