29.04.2013 Views

ACTIONSCRIPT 3.0

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> <strong>3.0</strong> DEVELOPER’S GUIDE<br />

Working with video<br />

Error #2095: flash.net.NetStream was unable to invoke callback onMetaData.<br />

Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint.<br />

Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint.<br />

Error #2095: flash.net.NetStream was unable to invoke callback onCuePoint.<br />

The errors occur because the NetStream object was unable to find an onMetaData or onCuePoint callback method.<br />

There are several ways to define these callback methods within your applications.<br />

More Help topics<br />

Flash Media Server: Handling metadata in streams<br />

Set the NetStream object’s client property to an Object<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

By setting the client property to either an Object or a subclass of NetStream, you can reroute the onMetaData and<br />

onCuePoint callback methods or ignore them completely. The following example demonstrates how you can use an<br />

empty Object to ignore the callback methods without listening for the asyncError event:<br />

var nc:NetConnection = new NetConnection();<br />

nc.connect(null);<br />

var customClient:Object = new Object();<br />

var ns:NetStream = new NetStream(nc);<br />

ns.client = customClient;<br />

ns.play("video.flv");<br />

var vid:Video = new Video();<br />

vid.attachNetStream(ns);<br />

addChild(vid);<br />

If you wanted to listen for either the onMetaData or onCuePoint callback methods, you would need to define methods<br />

to handle those callback methods, as shown in the following snippet:<br />

var customClient:Object = new Object();<br />

customClient.onMetaData = metaDataHandler;<br />

function metaDataHandler(infoObject:Object):void<br />

{<br />

trace("metadata");<br />

}<br />

The previous code listens for the onMetaData callback method and calls the metaDataHandler() method, which<br />

traces a string. If the Flash runtime encountered a cue point, no errors would be generated even though no<br />

onCuePoint callback method is defined.<br />

Create a custom class and define methods to handle the callback methods<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The following code sets the NetStream object’s client property to a custom class, CustomClient, which defines<br />

handlers for the callback methods:<br />

Last updated 4/22/2013<br />

488

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!