Free Text-to-Speech in Flash

There are several text-to-speech packages out there. But thanks to Google Translate, you can create a sort of "poor-man's" text-to-speech application in Flash. The method is a simple query string to the Google Translate service, which returns an MP3. Simply load that Mp3 into Flash, and voilà. The draw backs are that you only get on voice (although you can choose different languages which use an alternate accents) and you have a limit of 100 characters.

Check out the example and source code below.

import flash.events.MouseEvent;
import flash.media.Sound;
import flash.text.TextField;
import fl.controls.Button;
 
// stage instances
var input_txt:TextField;
var speak_btn:Button;
 
var speech:Sound;
var url:String = "http://translate.google.com/translate_tts?q=";
 
input_txt.maxChars = 100;
speak_btn.addEventListener(MouseEvent.CLICK, handleClick);
 
function handleClick(e:MouseEvent):void {
     speech= new Sound();
     speech.load(new URLRequest(url + input_txt.text));
     speech.play();
}


Reading Flash Alliance

Attention all Flash developers in the Reading, Pa area!!!

Be sure to check out the new Adobe Flash User Group in Reading. The Reading Flash Alliance is a group of Flash talent made up of local firms and freelancers who share ideas, knowledge, and talk shop. They are having a meeting next month and are giving away some prizes including a copy of Creative Suite 5. Pretty sick.

Go check 'em out. www.readingflashalliance.com



My 2010 Resolution Fail

Ok so, in the beginning of 2010 I made a New Years resolution that I would learn one new thing each week and blog about it. Like most resolutions, it went for three weeks and then failed miserably. Now I would normally look at this as a failed attempt to commit to learning. However, the reason that I'm not able to keep up with this is because I am just too damn busy. I'm 6 months into my new job at Neo-Pangea, and loving it. We are developing some really awesome Flash applications that push the limits and are just down right bitchin'. So it goes without saying that I "am" learning more and more as we continue to kick ass for our clients.



I Agree



Hulk Yourself

This is part of my 2010 resolution of learning something new each week. I've been playing around with using ActionScript's BitmapData and FileReference classes.

Use your webcam to position yourself in the frame. Then you can save an image to your hard drive. I still need to tweak some things, like adding controls to adjust the brightness. Press the "BEGIN" button to Hulk Yourself.



Flash Resolution-Week 3: Google Maps API + iPhone GPS Tracking

To build on my previous post about the Google Maps ActionScript API, I wanted to track the position of my iPhone in real time. I came across the site instamapper.com. After creating a free account with Instamapper and downloading their iPhone app from the Apple App Store, I was tracking my phone in no time. They have prebuilt maps that you can embed on your blog and even a Facebook application. Although I wanted to use my own map so I can have more control over the map. Instamapper has a simple little API that you can use to retrieve your information. A http call returns a string of all the data about your phone's location. Using a URLLoader to load in the request (http://www.instamapper.com/api?action=getPositions&key=584014439054448247) returns the data:

InstaMapper API v1.00
0071543339995,Demo car,1209252615,47.58822,-122.17969,25.0,27.7,349

The format of each record (seporated by commas) is as follows:

  1. Device key
  2. Device label
  3. Position timestamp in UTC (number of seconds since January 1, 1970)
  4. Latitude
  5. Longitude
  6. Altitude in meters
  7. Speed in meters / second
  8. Heading in degree

So using a split() method on the returned string, I could just parse the latitude and longitude coordinates and sent them to my Google map object. Here is a screen shot of my application. The only problem is that instamapper.com does not (yet) have a cross domain policy, which is not allowing the SWF on my server to access instamapper's server. Though it works just fine when run locally. So for now, this is just a proof of concept.



Flash Resolution-Week 2: Google Maps API

Incorporating Google Maps within Flash is one of those things that I always wanted to look into, but just never really had the time. Well it turns out that I actually did have the time, due to the fact that it only took me 10 minutes until I had a working example. I followed this tutorial from www.layersmagazine.com.

So in my example I simply mapped Mikey's house from The Goonies and inserted the Goonies logo. Yes, I am a little geeky that way. And if you don't like The Goonies please leave this site now. Just kidding.



Flash Resolution-Week 1: BitmapData & Trigonometry

A couple of areas that I'm trying to improve in are BitmapData and Trigonometry. Trig is really useful in Flash for working with angles and BitmapData can give some pretty cool effects.

I started this example by making a MovieClip rotate around a center point. I know I could have used TweenMax to rotate around a center point, but the idea here is to do the math, remember? Here are some posts I referenced. Kirupa, ActionScript.org.


After I got the MovieClip rotating, I decided to use it to create some interesting effects with BitmapData. I simply referenced the ActionScript 3.0 Language Reference for this.

[Move your mouse around the stage. The closer you get to the center cross hair, the smaller the ball's radius gets. Click and drag your mouse to draw lines from the center.]



My 2010 Flash Resolution

For a while I have been wanting to focus on the areas of Flash where I am weakest. So what better way to step up my game than to make a New Year's resolution.

My resolution:
Once a week I will learn something new and post a blog entry about it here. I don't claim that I will be doing any mind-blowing or uncharted discoveries or anything, but this will be an area where I will document my process. I hope it will help others who aren't familiar with some of these concepts, but it's mostly for me to keep tabs on myself.

We'll see how I do...



Switching to a Mac, and Switching ActionScript Editors

I recently purchased a new MacBook Pro that replaces my primary Dell desktop. But now that I'm on a Mac, I am no longer able to use Flash Develop as my ActionScript editor since its developed in .NET. So I've turned to Flex Builder 3 as my ActionScript editor of choice. It is a really great editor, although it does seem a bit bulky compared to Flash Develop.

So that led me to want to learn more about the Flex Framework (MXML). Something that I've been wanting to do for some time now, but now have more of an urgent reason. So currently, I am watching the Flex 3 Essential Training at Lynda.com. (Great site!) I figured that this will give me a great overview of Flex and a tour of the Flex Builder IDE.

I realize that I can get Parallels or Fusion for the Mac so I can run Windows based applications. Perhaps I will eventually. But this way I'll be able to get more into Flex like I've been wanting to.

We'll see in a few weeks how I like the transition.



« Previous Entries