How can Loading video files in AS3?

Answer Posted / dindayal dhakar

Loading videos using the NetStream and NetConnection
classes is a multistep process:
1. The first step is to create a NetConnection object.
The NetConnection class lets you play streaming FLV files
from either an HTTP address or a local drive by passing the
value null to the connect() method, if you are connecting
to a local FLV file that is not using a server such as
Adobe's Flash Media Server 2 or Adobe Flex.
2. var nc:NetConnection = new NetConnection();
3. nc.connect(null);
4. The second step is to create a NetStream object
which takes a NetConnection object as a parameter and
specify which FLV file you want to load. The following
snippet connects a NetStream object to the specified
NetConnection instance and loads an FLV named video.flv in
the same directory as the SWF file:
5. var ns:NetStream = new NetStream(nc);
6. ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR,
asyncErrorHandler);
7. ns.play("video.flv");
8. function asyncErrorHandler
(event:AsyncErrorEvent):void
9. {
10. // ignore error
11. }
12. The third step is to create a new Video object and
attach the previously created NetStream object using the
Video class's attachNetStream() method. Then you can add
the video object to the display list using the addChild()
method, as seen in the following snippet:
13. var vid:Video = new Video();
14. vid.attachNetStream(ns);
addChild(vid);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you insert record into scripting using siebel crm

5296


Difference between the SAP MDM vs IBM MDM in approach, the tools used , ease in handling/implementing.

6544


I have deducted tds on pay slip for employees ist month tell me how to deposit this amt to govt. by bank or any form is available fill the same and deposit the govt. department. Pls explain me which form to be used for deposit the same with due date.

3060


I Am Planning to Write ISTQB foundation level Ceritification of inida. can Any Body let me know how to prepare for it & Any Study material can you provide or Any other E-books i should need to Study. Please Mail to me ajaybe_2004@yahoo.co.in THnaks in advance Ajay

2031


what is the Structure of an ANT file?

2005


why script is client dependant.

2233


How can you convert QTP 8.2 scripts to QTP 9.2. Please give some inputs ASAP.

2617


If we add regular expressions to a script recorded in QTP, will it effect the performance of the script?

1990


Someone who protect my excel file, m using ms office 2007 and windows 7 operating system, pls help me, how can i unprotect sheet

2116


Why we use Action Script(Multimedia Flash) rather than using other scripting languages (JAVA,VB...etc) ?

2600


Would you tell me that what is test script? and how to write it? are there some templates?

2055


Need a batch file or VB script to delete old (more than 90datys) roaming profiles

2098


I have installed QTP version 9.0. I have installed Mozilla firefox version 2.0. But QTP "Record and Run settings" in WEB tab shows FIREFOX 1.5 in drop down to run session begins. So QTP does not record anything which I type in firefox. How can i recognise firefox 2.0 and how can i update browser version in QTP?

1962


database acl level has manager access.his name is listed in author and Reader fields. but he didn't sea a documents what is the reason?

2147


why do u need an ANT?

2239