Recently I have been working on something involving the use of video content from You Tube. With the lack of a good API out there I created my own. Below is a simple example of this working with sample code to download further below.
AS3 Example
Actionscript: import com.FlashDynamix.services.YouTube; import com.FlashDynamix.events.YouTubeEvent; // var yt:YouTube = new YouTube(); yt.APIKey = "WplekwLy_Nw"; function onLoaded(e:YouTubeEvent) { switch (e.method) { case YouTube.VIDEOSBYTAG : try { for each (var video:XML in data) { trace(video.name() + " : " + video); } trace("Videos For Tag : " + e.request.tag + " : " + e.data.length()); } catch (evt:ArgumentError) { trace("ERROR : No Videos For Tag"); } } } // yt.addEventListener(YouTubeEvent.COMPLETE, onLoaded); yt.videosbyTag("Top Gear");
AS2 example
Actionscript: import com.FlashDynamix.services.YouTube; // var yt:YouTube = new YouTube(); yt.APIKey = "WplekwLy_Nw"; var obj:Object = new Object(); obj.loaded = function(evt:EventArgs) { switch (evt.type) { case YouTube.VIDEOSBYTAG : var videos = evt.value.video; break; } }; // yt.addListeners(obj); yt.videosbyTag("Top Gear");
The class I created YouTube.as supports all the features listed on the YouTube API documentation here http://www.youtube.com/dev_docs
Download the source here