Support Center » Knowledgebase » Using FLV Player in Flex
 Using FLV Player in Flex
Article FLV Player is a CS3 and CS4 compatible component, but you can also use it within your Flex Builder projects.

Here are the steps involved in using FLV Player in your Flex projects.

First, we need to create the FLVplayer.swc file which will eventually be included in our Flex Library.

1) Create a new Actionscript 3.o file in either Flash CS3 or CS4.
2) Drag the FLV Player component onto the stage or directly into the Library.
3) Right click on the FLV Player component within the Library.
4) Select Export SWC File from the context menu and save the SWC file to your project folder. You can save it as FLVplayer.swc just to keep things simple.

That FLVplayer.swc file is now a compressed version of the entire FLV Player component. Next, we need to setup our Flex Builder project, and allow for the use of the component from within Flex.

1) Open Flex, and create a new Actionscript Project. Name this project FLVplayer.
2) Under Actionscript Build Path choose Library Path and click the Add SWC to browse to your FLVplayer.swc file and to add it to the project.

We also need to have our "flvplayer" directory available within the Flex Builder development environment. To do this, simply copy the "flvplayer" directory to the "html-template" folder. Or, just be sure to point to the "flvplayer" folder by using the component parameter flvpFolderLocation.

We're now ready to start using the component within Flex. All of the properties, methods, and API's that are available within FLV Player are now included in our Flex project.

Your Flex project would have automatically created our FLVplayer.as base class file. Here we simply need to specify things such as the Video Source, Width, Height, etc.

This is how to setup the FLVplayer.as file and to begin customizing any aspects using our available FLV Player FlashVar Component Parameters API.


package {

import com.flvplayer.FlvPlayer;
import flash.display.Sprite;

[SWF(width="570", height="400", frameRate="30", backgroundColor="#FFFFFF")]

public class FLVplayer extends Sprite
{

public var myVideo:FlvPlayer = new FlvPlayer();

public function FLVplayer()
{
myVideo.vidURL = "flvplayer/xml/videos.xml";
myVideo.width = 570;
myVideo.height = 400;
addChild(myVideo);
}
}

}


Flex treats FLV Player as a custom class - you would instantiate it the same way you instantiate any class in AS3. For our example, we could use something like:


var FLVplayer:FLVplayer = new FLVplayer();
addChild(FLVplayer);


This will initialize an instance of the FLV Player class whenever you need to create a new instance of the component within your Flex Application.



Have questions?
Contact DevBase Sales and Support


Article Details
Article ID: 40
Created On: 09 Nov 2009 2:39 PM

 This article was helpful  This article was not helpful

 Back
 Log in  
Username:
Password:
Remember Me:
 
 Search
 Article Options