I quite often find myself needing to find codes for special characters and then having to track down a website that lists the type of code I am after. Sometimes I need Unicode, other times I need ASCII, and other time I need URL Encoded values. Things like a list of key codes and escape sequences are also handy to have. So, to make mine (and your) life easier, I have put together a Special Characters Cheat Sheet (PDF) that lists all the characters from 0 - 255 (ASCII) and their other corresponding code values.
In AS3 there are a few more event properties we can access such as ctrlKey, shiftKey and altKey. There are also many more static constants which are mapped to certain keys on the keyboard. Here is the Flash 9 AS3 version of the above movie.
UPDATE 20/03/09:Lee Brimlow has just made me aware of a useful online tool for converting between Unicode and other representations such as Hex, CSS Escape Sequences and Percent Encoding for URIs. The tool is called Unicode Code Converter v6 and has been written by Richard Ishida.
In ActionScript 3 you can detect key presses on the keyboard using the Stage class. I discovered that the Stage object is not globally accessible. You need to access it through the stage property of a DisplayObject instance. So from within a Class you can check which keys are being pressed using the following code.
publicfunction KeyboardTest($base:MovieClip):void{ trace("KeyboardTest constructor is being run");
base=$base;
base.stage.addEventListener(KeyboardEvent.KEY_DOWN,keyboardListener); }
Today Adobe officially released Flex 3 and AIR (Adobe Integrated Runtime) for the desktop. I won’t say too much about them here, as there is already plenty of info out there in the blogosphere. If you want to find out more, follow the links provided.
Hooray, at last I have found a WordPress plugin that displays ActionScript just how I want. I’ve tried about four different plugins now and there was always something not quite right about them. What I wanted was;
code to be displayed in a block
ActionScript syntax highlighting (using something like GeSHi)
line numbering
ability to copy and paste the code without copying the line numbers
long lines of code to not break out of the display block (to use horizontal scroll bars on long lines)
ability to set a maximum height of display block (then use vertical scroll bars)
keep code indented
Here are some of the plugins that I used at start with, and found that each of them had a problem with at least one of the above requirments;
Finally, the that I have settled on is called CodeColorer by Dmytro Shteflyuk. This seems to do all of the above, and was pretty easy to install and tweak. More info can be found on Dmytro’s personal site. So all the code blocks that you see on this blog are formatted using the CodeColorer plugin.
To use the CodeColorer plugin, simply wrap your code in the following tags …
<code lang=”actionscript”>
</code>
UPDATE 11/04/08
I have now turned off line numbering, because the numbers were being copied and pasted into peoples ActionScript editor when visitors tried to get the source code.
Also, there is still a slight issue with this plugin. When you want to go back and Edit a post, you are automatically taken to the ‘Visual’ editor. Switching between ‘Visual’ and ‘Code’ mode breaks the syntax highlighting.
So if anyone know of a really solid code syntax highlighter, then I’d still like to hear about it.
Recently I’ve been reading up on the event handling in ActionScript 3. There is a lot about this in the docs, but it is spread all over the place. So I’ve decided to put together a quick list of the public constants that are available for the different objects.
In As3 you create an event listener to respond to an event that is dispatched by the object you are interested in. This is done using addEventListener. For example …
Last week I one of the designers I was working with came across a bug in Flash CS3, well I presume it is a bug. Basically they were trying to do a shape tween on a line, bending from one place to another on the screen. Nothing strange there. But the line is question was dotted. When the shape tween was applied the line lost all dotted appearance and reverted back to a normal stroke, and then became dotted again on the last keyframe. The same thing happened when the line was dashed.
Obviously I would have expected it to remain dotted throughout the duration of the shape tween. See below.
We then tried converting the line to a fill (Modify > Shape > Convert lines to fills), which nearly worked, but the tweening got confused and random dots started swapping places, plus the filesize got bigger.
Surely this is a bug. I have reported it to Adobe using their Bug Report Form.
I’ve been having a play with Tweener in AS3.0 and put together a little movie that demonstrates all the different easing type you can choose from. These are all based on the original Penner Easing Equations. This is very similar to Robert Penner’s Equations Visualizer. The duration for my tweens is set to one second.
Here is some AS3 code that moves a ball to the position of your mouse when you click. The CLICK event is triggered from a Sprite called ‘_canvas’ that is drawn through code. The ball is also a dynamically created Sprite called ‘_ball’. Create a blank FLA and set the Document Class to ‘Main’, then put this AS file next to the FLA and run Test Movie.
If you find yourself trying to remember the various import statements for AS3.0 classes, here is a list of some of the most common ones. If you are using Flex Builder or FDT these are put in for you automatically, but the Flash IDE doesn’t.
Last night was January’s London Flash Platform User Group meeting at the CosmoBar in Clerkenwell. The speakers were Paddy Keane talking about his experience of using PureMVC and Rob Bateman talking about the history of 3D on the web. The event was so popular that Tink had to send an email out to everybody warning that over 120 people had signed up to go, and that places would have to be on a first-come-first-served basis (normally we only get around 40 - 50 people). Anyway, here is a quick bullet point summary of what they covered.