Casting in Actionscript 3

I wanted to post something codey again, and this is a topic that can confuse some, so here we go.  This is actually a fairly broad topic, so I’m just going to cover some important things.

1. What is casting?
Casting is basically converting an object that is one type to another type.

2. Why do it?
There are numerous reasons – you’ll see them in the examples.  One main reason is that you have to sometimes.

3. How do you do it?
Good, on to the real meat.  There are to ways to explicitly cast (where you state it in your code) in ActionScript 3.  The first one is by  Type(myObject) .

var mySprite:Sprite = Sprite(randObject);

This takes a value of Type Number (5.5) and changes it to an integer, which is stored as myInt.

Continue reading

10 KB Nonogram Puzzle Game

Just released Nonogram Puzzlers, a flash game under 10 KB made in 10 days for a contest.  It’s a collection of 8 nonogram puzzles (also known as paint by number, griddler, or tsunami) made by me and one by a friend.  It also contains a user creation section.  It turned out well for the file size limit, I just didn’t get to polish it as much as I hoped because of the time constraints.  The actual solving interface turned out well, and is easy to use.  My biggest regret is that if you switch puzzles, your progress on your previous puzzle is erased.  Anyway, try it out and let me know what you think.  All are solvable by logic, except #9, which will probably take some guess and check.



Custom Cursors Demo in FP 10.2

You will need Flash Player 10.2 to view this!

Since FP10.2 is out, I thought I’d make a custom cursors demo. It relies on two outside libraries, MinimalComps and as3Gif. The project files are here! The demo demonstrates a static cursor, an animated one, and one you can draw in the program.

Continue reading

Flash Player 10.2 and Custom Cursors

About a month ago, Flash Player 10.2 was announced.  Lost in all the hoopla about the upcoming Flash Player 11 with low-level 3-D APIs and StageVideo of FP 10.2, was the introduction of custom cursors.  (Check out the docs here.) This should hopefully alleviate the pains of those who previously had to have an Mouse Move listener move a sprite to mouse coordinates, and will definitely provide a source of easy unlockables for games.

Continue reading

Text to Speech Fun

The possibilities for working with sound in ActionScript have been expanded with the relatively new SampleData event: you can now record sound from the microphone into a ByteArray or play sound dynamically from a ByteArray. This opens up the potential for all kinds of cool things, and I came across one example of this from Kelvin Luck, a class that plays back sounds at different speeds.

Also cool is the Google Translate text to speech webservice, which can be used to retrieve an mp3 file from a text query. Pete Shand circumvents the 100-character limit with his TextToSpeech class.

Combining these two I made a cool little application (just type in text, and press Hear):
Vodpod videos no longer available.


(If the swf doesn’t load, try here.)

Continue reading

Embedding an SWF on WordPress

This is going to be pretty easy actually, using a nifty little tool from vodpod:

  1. Go here and drag the icon to your bookmark bar
  2. Go to a website containing your swf. Here is where you have to be careful: some websites will work with the tool and others won’t. I’ve found that YouTube and SwfCabin work, but MegaSWF does not.
  3. Click the bookmark you just added and it should select your swf automatically. Then fill out the information and either post it directly or send it to be edited.
  4. That’s pretty much it: be sure to preview it first.

I wish vodpod would just give you the code instead of forcing you to type in your username and password, but I believe they are a trustworthy tool.

Here’s a movie off YouTube:

Vodpod videos no longer available.

Continue reading