« You Tube Flash AS3 / AS2 API»
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
-
import com.flashdynamix.services.YouTube;
-
import com.flashdynamix.events.YouTubeEvent;
-
//
-
var yt:YouTube = new YouTube();
-
yt.clientKey = "ytapi-ShaneMcCartney-flashdynamix-vuj2k916-0";
-
function onLoaded(e:YouTubeEvent) {
-
switch (e.method) {
-
case YouTube.SEARCH :
-
for each (var video:YouTubeVideo in e.data.list) {
-
trace(video);
-
}
-
break;
-
}
-
}
-
//
-
yt.addEventListener(YouTubeEvent.COMPLETE, onLoaded);
-
yt.videosForTag("Top Gear");
AS2 example
-
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 both the legacy and current version of the YouTube API legacy documentation and current documentation.
Download the source from the following SVN details
SVN: http://youtubeas3.googlecode.com/svn/trunk/
Don't have an SVN client? I recommend you use Tortoise - get it here or if you're an Eclipse user try Subclipse



235 Comments