« 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.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
-
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 here

96 Comments