Tutorial - Creating a reusable Slider Control / Component

Hi Everyone,

Today I will cover the subject of creating a reusable slider control which takes two bitmaps as resources. The thumb bitmap will slide on the rail bitmap. It is a very simple concept!

We will basically take this image:
and this one:
and make this (try it, move that knob):


In fact, the code you are about to write will take ANY two images and create a slider with them. Just like magic, as long as your images make some sense ( a track and a button ), it should be golden!

Starting Point
When I started writing this tutorial, I was still using the Flash IDE; but since then I am free!! I now use exclusively FlashDevelop. With that in mind, the package to start the coding, if you want to follow along is here. You will need FlashDevelop & the Flex SDK 3.4 or newer.
Read more…

Tutorial - Multi Touch in AS3 / Flash Player 10.1 - Part 2. TouchEvent & MouseEvent Sequences

Hi Everyone,

In this installment I will cover the TouchEvent and how it is intertwined with MouseEvent. First you need to understand that touches will fire MouseEvent’s too. You will get a TouchEvent first, then a MouseEvent. This can prove annoying in some cases, and good in others.

For the complete listing of TouchEvent’s as well as some basic description of the information it carries please refer to this page.
Read more…

Tutorial - Multi Touch in AS3 / Flash Player 10.1 - Part 1. Setting Up

Hi Everyone,

I had the pleasure, although it was a strenuous experience, to work on Adobe Post. It is still a private project; undertaken by 80/20 Studio in NYC on behalf of Adobe. It was demonstrated (shortly) by Kevin Lynch at the Adobe MAX conference on Oct 14th, 2009. It implements one of the nicest new features of Flash Player 10.1: Multi-Touch.

Read more…

TubeGripClient - Play Any Movie on YouTube in AS3 with your own player!

Hi Everyone,

as some of you might have noticed, KeepVid went downhill. I don't know exactly when, however I found an alternative: http://www.tubegrip.com. It works pretty well...

Here is a sample use of this library:

Actionscript:
  1. public function startTest():void
  2. {
  3.     _client = TubeGripClient.getInstance();
  4.  
  5.     // this takes a url from YouTube they call Watch Urls.. basically, the url you get when you try
  6.     // to share a video with a friend...
  7.     _client.getFLVUrl("http://www.youtube.com/watch?v=WPzgGs_cHWo");
  8.     _client.addEventListener(TubeGripEvent.URL_READY, doUrlReady);
  9.     _client.addEventListener(TubeGripEvent.REQUEST_FAILED, doRequestFailed);
  10. }
  11.        
  12. protected function doUrlReady(evt:TubeGripEvent):void
  13. {
  14.     trace("urls are:");
  15.     trace("[flv] " + evt.flvUrl);
  16.     trace("[hd] " + evt.hdUrl);
  17.     trace("[hq] " + evt.hqUrl);
  18. }
  19.        
  20. protected function doRequestFailed(evt:TubeGripEvent):void
  21. {
  22.     trace("request failed.. for whatever reason");
  23. }

Read more...

Tutorial - Consuming REST web services in ActionScript 3 - Part 4

Hi Everyone,

this is a follow-up to the following posts:

In this post, I will add code to identify each request uniquely, give you a class called "AbstractClient" that will handle most of the mechanics and is easily extended. The idea is to give you a base on which to build. Essentially, for every service call you will want to make you will need 2 functions:

  • A public function that will send the request out
  • a protected function that will receive the response, digest it and dispatch an event

For those who'd like to go ahead and enjoy the goods right away, I will write this tutorial so it can be read and understood on it's own.

Read more...

Tutorial - Playing FLV video in plain AS3 - Part 4 - Sample Usage

Hi Everyone..

This is the fourth (and most probably the last) installment of this series on playing FLV (and H.264 MP4) video in Flash from scratch.

Full source code for the library is here.

The related posts are:

For many of you, this might be the only post you are interested in. It will show you how to use the library.

Read more...

Tutorial - Playing Video with SubTitles in AS3 - Part 1

Hi Everyone,

The series on Playing FLV files in AS3 was probably the most popular post on this blog. So I thought I would take it one step further: show SubTitles from an .SRT file over the FLV while it is playing.

First, you need to read this post by Jankees van Woezik. He did a great job at making a SRT parser, although; well, I wouldn't convert everything right away but rather do it on-demand; but that is a small detail.

Then you need to find yourself a SRT file. There are plenty on the internet, I took the Star Wars subtitles, changed the time a little bit, and ended up with this SRT file.

The video I chose I got using TubeGrip, it is basically a Telemark skiing video, which I love and miss. This video is a mp4 format using H.264 codec, which is supported by Flash Player 10 and over. Much more pretty. You can get those from TubeGrip off YouTube.

Read more...

SWF TextField Factory — Dynamically Loading Fonts in AS3 using Flex SDK 3.4

Hi Everyone,

it has been a long while since I wrote! Been busy. Now I have some time and the first thing I did is to get away from the Flash IDE completely. I had been waiting to be able to debug directly in FlashDevelop for a while, tried some extension that didn't work, then Philippe did actually fix another one and it works beautifully. You can find the link here, look for Version 0.9.7 at the bottom of the first post. Unzip into your FlashDevelop plug-ins folder, restart FlashDevelop and bravo!

So I am Flash IDE Free!! Woohooo. Then the first thing I wanted to master is the Preloader, and FlashDevelop has a very nice "AS3 with Preloader" project template. It is very easy to work with. Very beautiful.

Now the next challenge, loading fonts dynamically. Euh, well, I used to do it from a FLA, was easy. But using the Flex SDK 3.4 it seems that some things changed. After HOURS of playing around, I ended up with the following system:

  • embed the font inside of a swf that contains a Main class + the font class
  • create a function that will spawn textfields already using the font inside this Main class

Although this system has some limitations, it works beautifully.

Read more...

tutorials.as3.ca is online!

Hi everyone,

although right now it doesn't look like much, I spent the last day compiling the best AS3 tutorials I could find on the internet. I have good ideas for this site, and I hope I will get the time to make it a reality. For now it will just serve to boost the indexing spot on search engines for those tutorials, but .. you know... it'll come!

have a look for yourselves (yes, I know it is ugly). I am no designer.. http://tutorials.as3.ca

Take good care, much to come in december as I finally have a break from work and I am not travelling!!! :)

Martin

Should we start learning Javascript once again?

Hi Everyone,

with HTML 5 being adopted by more and more browsers out there, with DailyMotion releasing an HTML5 version of the movie profile page, and YouTube doing the same; there comes a question: should I get back to learning Javascript?

The posts on the subject abound all over the internet:

HTML 5 versus Flash / Flex

Adobe was heard saying:

It might be a decade before HTML 5 sees standardization across the number of browsers that are going to be out there (...)

Right.. I think it will take 2 years. I think in 2 years, you better get really good with the Google Web Toolkit if you want to be on the cutting edge. Otherwise, you can wait 4-5 years. And who will save our jobs: Microsoft. By being the shittiest browser out there, Internet Explorer will help keep the value of actionscript knowledge high for atleast another 2 years.

That is my take. What is yours?

:)

Martin