Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I convert this AS2 function to AS3 which receives data from a stream.

Posted on 2010-09-10
4
Medium Priority
?
377 Views
Last Modified: 2013-11-11
Hi Experts,

I have been using an Adobe example that you can find here.

http://www.adobe.com/devnet/flashmediaserver/articles/metadata_video_streaming.html

I have made it work really well.  I now want to use the Openvdeoplayer (http://openvideoplayer.sourceforge.net/) and code in as3.  I am trying to convert the function that receives the text and shows it in a box under the player.  The original as2 function was the following.

my_ns.onDataEvent = function(str) {
   _root.display_txt.text = str;
};

I have written the following version

public function onDataEvent(str:String):void {
 display_txt.text = "test " + str;
}

But I can see that it is not listening to the stream. I thought that I should be using 'addEventListener', but I am getting nowhere.  I am using the Akamai example CS4sampleLive and I have attached both files.  They compile fine but into a nice swf but they don't pick up the data.  I am still using the orignial code in the main.asc on my fms 3.5 server and the insert.swf.

I hope that it is something simple that I am missing.

Thanks
CS4sampleLive.as
CS4sampleLive.fla
0
Comment
Question by:emincote
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 3

Expert Comment

by:cconstable_work
ID: 33659521
You would need something like:
display_txt.addEventListener(DataEvent.DATA) {
display_txt.text = "test " + str;
}

However I don't believe you can pass variables to an event listener so you would have to get str from elsewhere.
0
 
LVL 3

Accepted Solution

by:
cconstable_work earned 2000 total points
ID: 33659550
Sorry more like this:

import flash.events.DataEvent;

display_txt.addEventListener(DataEvent.DATA, yourFunction);
function yourFunction(e:DataEvent):void {
      display_txt.text = "test " + str;
}
0
 

Author Comment

by:emincote
ID: 33660213
Hi,

Many thanks for this, I have added it within the last public function and it compiles correctly.  I think I understand what is going on, but will have to wait a little until I can test all the way through as I am out of the office at the moment.

Kind regards

Emincote
0
 

Author Comment

by:emincote
ID: 33701478
HI,

I am happy to accept your solution and close this, but for interests sake I dug right down into the OPV code and in the end used OvpEvent.NETSTREAM_TEXTDATA which had a data type of data in my function.  So with great joy it all worked.

Hope this helps others,

Emincote
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question