NetStream() and CuePoints
Hi,
Iv recently started using flash again after a few years of neglect (I finally have a job that pushes me!) and I'm finding I'm a little rusty...
Very simply Im having some issues creating reactions to CuePoints when using NetStream();
I can get what I want to work when the video is embedded directly onto the stage by using the following code:
vid.addEventListener(MetadataEvent.CUE_POINT, cp_listener);
function cp_listener(eventObject:MetadataEvent):void {
obj = eventObject.info.parameters;
for (key in obj) {
if (key == "CuePointName1") {
// then do whatever I want to happen when CuePointName1 is reached in the video
}
}
But when I translate it over to work with NetStream it doesn't work:
// START NETSTREAM
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
ns.client = this;
ns.play("video.flv");
var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
// CUEPOINT LISTENERS
function onCuePoint(infoObject:Object):void {
for (key in infoObject) {
trace(infoObject["name"]);
if (infoObject["name"] == "CuePointName1") {
// then do whatever I want to happen when CuePointName1 is reached in the video
}
}
}
The trace statement is returning the name of the CuePoint correctly, but 4 times like this:
CuePointName1
CuePointName1
CuePointName1
CuePointName1
Witch I assume is why the if statement isn't picking it up.
Any help will be most appreciated!
Thanks
Ross
