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

Actionscript:
  1. import com.FlashDynamix.services.YouTube;
  2. import com.FlashDynamix.events.YouTubeEvent;
  3. //
  4. var yt:YouTube = new YouTube();
  5. yt.APIKey = "WplekwLy_Nw";
  6. function onLoaded(e:YouTubeEvent) {
  7.     switch (e.method) {
  8.         case YouTube.VIDEOSBYTAG :
  9.         try {
  10.             for each (var video:XML in data) {
  11.                 trace(video.name() + " : " + video);
  12.             }
  13.             trace("Videos For Tag : " + e.request.tag + " : " + e.data.length());
  14.         } catch (evt:ArgumentError) {
  15.             trace("ERROR : No Videos For Tag");
  16.         }
  17.     }
  18. }
  19. //
  20. yt.addEventListener(YouTubeEvent.COMPLETE, onLoaded);
  21. yt.videosbyTag("Top Gear");

AS2 example

Actionscript:
  1. import com.FlashDynamix.services.YouTube;
  2. //
  3. var yt:YouTube = new YouTube();
  4. yt.APIKey = "WplekwLy_Nw";
  5. var obj:Object = new Object();
  6. obj.loaded = function(evt:EventArgs) {
  7.     switch (evt.type) {
  8.         case YouTube.VIDEOSBYTAG :
  9.             var videos = evt.value.video;
  10.         break;
  11.     }
  12. };
  13. //
  14. yt.addListeners(obj);
  15. 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

The Seeker : The Dark Is RisingFor 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.

Check out the site

Have your say | Filed Under: Work | The Post ›

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!

Become Johnny Storm the Human TorchThe 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.

Visit the site - Flame On!

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 :

  • Graham Scan
  • Melkman
  • Jarvis March
  • BFP
  • 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




    Me

    I am Shane McCartney a Flash Developer who's currently not employeed and moving to London at the end of March 2008. If you would like me to do some contract work for you contact me at shanem@flashdynamix.com.

    Donate

    If you find the source code or information provided on this site of such use that you would like to donate please do it is appreciated.

    Your donation will help us to provide even more source code to the community and cover the cost of time to develop and maintain the source code we provide, thank you.