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
The Seeker : The Dark Is Rising
For the last month I have been working on 2 phases of a movie site called the The Seeker : The Dark Is Rising. The Seeker is Eragon meets Harry Potter meets Peter Pan which has been a challenge in it's self. Though additionally to this it's been even more challenging to get through the build as the site is completely multilingual with exchangeable fonts. This sites a big load I know but the guys wanted epic and they got it in file size too - but hey those are some nice animations. One interesting part to the site is the ability for users to unlock site content by codes / sign sequences found on external media. Then like many movie sites people can embed some Flash into there page to track there progress of finding the signs you can see mine below.
There are also 6 mini games which can be embedded in webpages here.
Douglas Peuker Line Generalization
Just recently I have been working on some code which required line generalization for Flash from drawings / poly line data. I have posted up sample code and a demonstration SWF to show the results of these tests. I found that the Douglas Peuker algorithm was the simplest to implement the results are pretty good. The only down point is code only usually runs in O(n log m) time where m the number of points is small. I would like to try and speed this up by a technique using the Melkman convex hull algorithm based on a paper written by Hershberger & Snoeyink they split the lower and higher bounds to increase performance on the simplification process.
Download the source code here
Fantastic 4 - See Yourself On Fire And Record It!
The Flame On site promotes the sequel movie for Fantastic Four - Rise of the Silver Surfer. Using the site and a web camera you can see your self on fire just like the Human Torch character from the film. You can either use the site as a toy or record a 10 second video clip. Which you can send onto friends or embed the 'FlameOn'
code into your website. Using the 'Flame On' code you can further personalize the video by writing out your name or message in fire for those who are not content with just seeing themselves in fire.
On a technical note the site uses Flash Media Server 2 to record the clips. This is our first experiment in using this particular revision of Flash technology last time for me was Flash Communication Server way back when.
For me I find this type of site interesting to monitor the ratio's of people using this site as it hinges completely on having a web camera so I'll be keeping an eye over the stats for the next few weeks as the movie is out in cinemas in the US yesterday and Australia June the 21st.
Convex Hull Algorithms for Actionscript
Recently I have been playing around with some code that required the use of Convex Hull's but I couldn't find any one who had ported these algorithms to Actionscript. If you don't know about Convex Hull's you can read about them here. I have written the Convex Hull Class to work with a few of the popular algorithms as I was playing around with the pro's and con's of using each including :
An example SWF (AS2.0) using the ConvexHull.as Class is below (only with the Graham Scan Algorithm are the points draggable). I am surre if this was in AS3 it would run alot faster as most the memory is used in loop sorts
To download the source click here
