Archive for the 'Flash' Category

Page 2 of 4

Heres some programming tid bits that really didn’t deserve their own post, so I grouped them all together into one post! :P


We all know about the common


language construct that is available in almost all programming languages, but here one you might of not been aware of: the else-switch statement.

if(false) {
} else switch(number) {
    case 0:
        //do something
    case 1:
        //do something else
        //do default action

Actually, you can follow if with any control statement. For instance, you can have an else-return or an else-break statement. This might be old news to some programmers, but I never knew you could do that!

Declare Variables Inside a switch Statement

I never had to do this before, but recently I needed to declare some variables inside a switch statement. A little googling revealed that variable declaration inside a switch statement is possible:

switch(something) {
    case 1: {
        int a; //a variable is declared!

All you have to do is enclose your


statement with brackets and you can define all the local variables you want.

Reset mySQL’s


I love mySQL’s auto increment feature, but while developing applications using mySQL I sometimes need to reset the auto_increment counter. The follow code snippet will reset your


so the next database record id will be 0:


Text Conversion Utility

MacDevCenter has a nice article on a ‘hidden’ text conversion utility,


thats bundled with the os x dev tools.


Something that I’ve always hated about javascript is the lack of reusable libraries and classes. Finally their has been some movement to standardize alot of common javascript tasks, not just to post ad-hoc solutions on the various script sites out there. You can get a comprehensive list of the various libraries available here.

F-Script Anywhere

This is one of the coolest things that I’ve come across for OS X. F-Script anywhere lets you look inside a program while its running. You can call methods of objects, inspect the properties of UI elements. It’s pretty incredible. You’ll need to get the F-Script Framework before you can use the F-Script Anywhere SIMBL plug-in.

Objective-C Instance Variable Initialization

In objective-C their is no need to initialize your instance variables to nil/NULL (you normally should initialize all variables to nil/NULL, or some other initial value for reasons described in this article). This is already done for you in the


method of an object.

Carbon Data Types

Its hard to me to understand Carbon code well because of all the ‘opaque’ data types used by Carbon. At first glance what is


? Is it a


? An

unsigned int

? A


? Theirs no documentation of these data types in the Apple docs anywhere, so I went looking around to see if i could find the header files that contained the definitions for the various data types. Luckily my search was not in vain:


The above directory contains the definitions for most common Carbon data types, the majority of common Carbon data type definitions are located in the following header file:


Initializing All Elements of a C-Array to 0

You can easily initialize all elements of a C array to zero by initializing the first element of the array to 0 using the “bracket initialization” method:

int intArray[1000] = {0};

The above code will initialize all 1000 elements of


to 0. All elements that aren’t given a initial value using “bracket initialization” are given an initial value of 0.

Average Rating: 4.4 out of 5 based on 188 user reviews.

I’ve had this hanging around for awhile now, I just haven’t had a chance to package it up and put it out there: XASH 1.1.

Alot of changes have been made in this release:

  • Book filtering
  • Window position & size are saved
  • Constraint on min left splitview width added
  • The help window will appear automatically when XASH is ‘clicked on’ (activated)
  • Groundwork is laid for live searching
  • Fixed bug where nothing would appear in the left document outline
  • Window title now represents what page you are currently viewing
  • flash 7/flash 8 root help directory paths can now be specified by the preferences keys f7Path and f8Path
  • You can specify additionally directorys to be searched for help files through the preference key additionalSearchPaths
  • Redid the program structure (now their is only one .nib file containing all the objects)
  • Added an application icon
  • XASH is now a universal binary

I added the ability to specify the paths to your flash 7 and flash 8 help file directories along with the ability to specify additional paths to search for help files at. I was too lazy to write a GUI allowing you edit this, so if you want to change the default values your going to either have to use the


command line application, or Apple’s Property List Editor (included with the dev tools). Here a list of the keys that would want to edit in the


files located in



  • f7Path

    - string, path to the Flash 7′s help files directory. The default value for this is:

    /Users/Shared/Library/Application Support/Macromedia/Flash MX 2004/en/Configuration/HelpPanel/Help/
  • f8Path

    - string, path to the Flash 8′s help files directory. The default value for this is:

    /Users/Shared/Library/Application Support/Macromedia/Flash 8/en/Configuration/HelpPanel/Help/
  • f7Index

    - string, URL file path referencing the main index file Flash 7′s help files. The default value is:

  • f8Index

    - string, URL file path referencing the main index file Flash 8′s help files. The default value is:

    file:///Users/Shared/Library/Application%20Support/Macromedia/Flash%20MX2004 /en/Configuration/HelpPanel/Help/Welcome/Welcome_help.html
  • additionalSearchPaths

    - array of directory paths representing other directories to search for Flash help files at. The default value is an array with a single element whose value is:

    ~/Library/Application Support/Macromedia/Flash MX 2004/en/Configuration/HelpPanel/Help/

Please send me any feedback you may have.

Average Rating: 5 out of 5 based on 264 user reviews.

I’ve tried the whole Eclispe setup, but I’m just too used to Xcode to really like it.

So I decided to improve the support of Actionscript/Flash Development in Xcode. In my opinion, for optimal development speed we need the following components in the Actionscript-Xcode system:

  • Easy MTASC compiling with optional file pre-processing support
  • Easy documentation creation
  • Integration of Flash debugging into Xcode’s run log
  • Full code-sense support
  • Flash help file access without the Flash IDE
  • Visual layout of graphics, textfields, MC’s, and vector graphics without the Flash IDE

I already have some work done in some of these areas:

I am working on a new Xcode project template that will allow integrated pre-processing & compiling of Actionscript along with easy documentation creation. This is a huge improvement over the last method, but it still isn’t perfect. I’ve done some research to see if it would be possible to make MTASC integrate seamlessly into Xcode by writing a native Xcode plugin, its definitely possible and somebody has already done alot of reverse engineering and made a plug-in for Objective-Calm.

I’ve written a BASH script that generates a list of key words from a specified class path to be used with Xcodes code sense. Although this works, its not nearly as nice has having ‘real’ code sense, but Apple has kept their API for Xcode’s source scanner class closed preventing the creation of custom source scanners.

I released XASH a little while ago allowing Flash help file access without the IDE, it still needs alot of work; but at least its usable.

Intergrated Xcode debugging is something that I’ve always thought would be incredibly awesome, but only actually realized that it could actually be accomplished within the last few months. The basic idea is you specify a custom executable and run it within Xcode. The custom executable will be a server application which will accept XMLSocket connections and redirect all input from any XMLSocket connections into


. Since the server application was launched with Xcode both




are redirected into Xcode’s run log thus any input received from any XMLSocket connections will be displayed in the run log. I’m working on implementing the server application in Java and adding easy access to the ‘trace server’ (the executable allowing output to be shown in the run log) from my


class. When I’m all done all you’ll need to do to redirect output to the ‘trace server’ is to call


and once a socket connection is established all output send to


will be redirected to the ‘trace server’. The Java server will support multiple connections so it can receive trace output from multiple SWF’s. Heres a screen shot of a SWF’s trace output being redirected to Xcode’s run Log: Flash Debugging Within Xcodes Run Log

Visual layout of graphics, textfields, etc, etc would be really cool also. A project like this would actually be possible using SWFMILL as the underlying engine to create the SWF.

I’m working on getting everything packaged up and documented so I can release it into the wild.

Average Rating: 4.7 out of 5 based on 248 user reviews.

A few weeks ago I was searching around trying to decide what documentation system to use in my Actionscript/Flash projects. There are alot of options out there, but these are the ones that I found viable for my situation:

As2api: overall as2api seems like a good solution but I really didn’t like the style of the documentation as2api created and the os x binary didn’t seem to work on os x.

AS2Doc: looks like a good package, but it costs money; I cant see paying for something that has a free alternative which has very similar functionality. I’d rather donate to an open-source project.

VisDoc: looked really nice- exactly what I was looking for, I was very close to buying it until I saw NaturalDocs.

NaturalDocs: this turned out to be my final choice. NaturalDocs is OSS written in pearl so it will run on any OS that supports pearl. Using NaturalDocs is easy enough and it produces very nice looking documentation. The only downside is that currently it does not support JavaDoc style comments (this is on NaturalDocs to-do list), but this really wasn’t a big deal since learning NaturalDoc style commenting was very easy.

Average Rating: 4.6 out of 5 based on 254 user reviews.

Woot! :) The Flash 8 IDE has finally been announced! I have high hopes for this Flash IDE release since the Flash IDE on the mac right now totally stinks. Luckily, the beta testers are able to talk, I’ve searched around looking for anything about performance improvements on the Mac IDE, and I’ve found it. Heres a quote from their blog post:

“greatly improved performance on Mac OS X”

YESS! I hope with improved performance they fixed the ULTRA slow redrawing of panels, fixed the utterly horrible built in code editor, improved compiler speed by 200%, and added tabbed windows. Keep your fingers crossed.

If you dont have Flash yet, and are looking to buy it, there is a little tip at the end of the blog post I linked to above that will allow you to get the whole studio 8 (which includes Dreamweaver 8, Flash Professional 8, Fireworks 8, Contribute 3, and FlashPaper 2) for simply the upgrade price of Studio 8 $400:

“Aside from all the other nice stuff you’ll find in Studio 8, its pricing is worthy of particular note. For the first time, Macromedia is offering a single upgrade price for Studio 8 of US$399, which lets you upgrade from any prior version of the studio or one of its component products to the full Studio 8 (which now includes Flash Professional). So if you don’t already have one of these products, it would be worth checking eBay now for a cheap, legitimate copy of, say, Flash 3. You could probably find it for less than $20, but having that serial number will mean you’ll only need to pay the upgrade price of US$399 for Studio 8, not the full price of US$999.”

So basically, you can buy Flash 4 off e-bay for $20, then pay $400 to get Studio 8. Not a bad deal, the same price as if you got Flash Basic by itself. I’m pre-ording right now to get that cool backpack :P

UPDATE: Here’s an interesting piece of information from the Macworld newsletter:

“Flash 8 Professional comes with many new features including higher-quality video and improved text tools, but Macromedia also focused on improving the experience for Mac users. Document tabs are now included in both Flash 8 Professional and Dreamweaver, a feature that was available for Windows in the last version of the suite. Macromedia also moved to Mach-O for both Dreamweaver and Flash, bringing it closer to native Mac OS X APIs.

Flash Player 8 will now use Apple supported Open-GL to render graphics, a move the Macromedia says brings performance very close to its Windows counterpart.
Flash 8 Professional also includes Filters, which allow designs to be made with built-in filter effects like drop shadow, blur, glow, bevel, gradient bevel and color adjust. Adding the filters does not increase the file size of the Flash file because Flash Player 8 renders the filters in real-time. Another addition to the latest version of Flash is a new font rendering engine called FlashType intended to provide clear, high-quality font rendering.”

Sweetness! Sounds like MM spent some time on the Mac IDE this time around. I’m getting very excited about this release :)

Average Rating: 4.4 out of 5 based on 182 user reviews.

I came across this bug awhile ago. Lets say you had the following code in a SWF:

noise = new Sound();

It worked perfectly, the sound with the linkage ID in my library names “asound” played and everything was great.
Now try loading that SWF info another SWF, the sound will not play. I searched the net and found this nice little comment here:

“For what it is worth, I had the same issue, and found a solution to this.
When declaring the “new Sound”, you have to specify a target movie clip. For example:
new_sound = new Sound(this)”

Ah-Ha! Specifying this in the Sound object’s constructor magically makes it work. This isn’t anywhere in MM’s docs. Thanks MM for wasting 30 more minutes of my time!

Average Rating: 4.9 out of 5 based on 287 user reviews.