Stay Connected

Get Your Site Submitted for Free in the World's Largest B2B Directory!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

Navigation

Home

About

Tutorials

Featured Sites

Newsletter

FLADownloads

Forum

Jayde

iEntry

Advertise

Contact Us







Embedding & Controlling Flash Video With Actionscript

By Charlie Campbell
Staff Writer
Article Date: 2006-12-06

Of late, there's no questioning the ubiquity of flash video on the web: Google, Yahoo, YouTube, etc..

Given this presence (and consequent validity) more folks and more folks are entering into Flash development. Thus, the trend in web video is a boon to development, but in what vein?

Inherently, video needs a method of playback; a VCR, if you will. Flash player is (technically) our VCR, though it needs a bit of molding, as it comes "buttonless."

By this, I mean that one cannot simply embed a video and immediately have playback. Through Flash 8, Adobe provides a fairly simple method for importing clips. One adds pre-designed buttons and sliders by attaching a "skin" through an "import video" wizard.

Options then include: streaming said flv from a Flash Communications server or offering it as a progressive download. Either way, an swf file is created, referencing the "skin" and the flv, effectively creating a "dedicated player" of sorts. This swf contains a hard link to that flv file (or stream) and the skin file forever... so for each production you'll have to manage three individual files! Sound a bit messy?

The real power of Flash video is in the hands of Actionscript developers. While most tinkerers can embed a video, it's simply not a flexible or sophisticated method. What if you need to control playback via function calls? Nearly impossible.

What happens when something changes? A reprocessing of all previously published swfs!

What about a customized GUI? Anyone who's seen Jen deHaan's Flash skin-making tutorial knows how complicated this can be. Why suffer through draconian "skin" file standards and other nightmares when you can weave a bit of Actionscript?

Here at WebProNews' Video Blog ( like Google, YouTube and Yahoo ) we've opted for a more organized, Actionscript alternative: feeding video into a Flash application via externalized variables. Any method of importing data into Flash will suffice (in our case, we're utilizing a script creating dynamic XML ).

In this manner, a video symbol is created from which the flv plays. This is referenced in Actionscript which controls this symbol using attachVideo on a NetStream object. Here's the proof of concept:
    var nc = new NetConnection();
    nc.connect( null );

    var stream_ns:NetStream = new NetStream(nc);

    video_mc.attachVideo(stream_ns);
    //video_mc is the name of the video symbol placed on the stage

    stream_ns.play(path_to_flv);
At this point, the flv will be embedded into video_mc and begin playing. Flash's NetStream functions can be performed on stream_ns to pause, play, seek, and gather information about the newly embedded video.

It's a magical moment when this all comes together. Suddenly, flv lives up to the hype... you have it under your thumb. The possibilities are endless and exist within a familiar environment.

Tag:

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark WebProNews:

About the Author:
Charlie is a videographer, web developer and occasional correspondent for the WebProNews Video Blog.



 
 
Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact | Site Map

FlashNewz is an iEntry.com publication
© 1998-2008 iEntry Inc. All Rights Reserved Privacy Policy Legal