Wednesday, August 24, 2005

TimeOut class

Some time ago I created a TimeOut class which used flash's setInterval command, I've become less and less pleased with the way setInterval works, specifically in tracking interval ID's and so on.

Since they are difficult to track I've decided to use a different method using a temporary MovieClip instance instead, this isn't ideal either, but keeping tabs on a MovieClip is a lot simpler and more reliable.

I'd be interested to hear how other people have dealt with the problem, in most cases I keep things in a sequence or use an event dispatcher so that timeout's aren't required, but sometimes I just need to use one, usually when I'm being lazy.

Anyway, here's the code...

/*
Class: TimeOut

Description:
A TimeOut class which uses a temporary MovieClip to perform timing,
as opposed to setInterval which is messy.

Usage:
:myTimer = new TimeOut(_root:MovieClip, 10:Number, this:Object, myFunction:Function, arguments:Array);

Version:
24-08-2005

Author:
Jason Milkins | jason@mentalaxis.com | 
*/
class TimeOut
{
 /*
 Property: exFunction

 Description:
 Callback function

 Datatype:
 Function

 Access:
 [Private]

 */
 private var exFunction : Function;
 /*
 Property: exObj

 Description:
 Callback object

 Datatype:
 Object

 Access:
 [Private]

 */
 private var exObj : Object;
 /*
 Property: exArgs

 Description:
 Arguments to be sent to the callback function

 Datatype:
 Array

 Access:
 [Private]

 */
 private var exArgs : Array;
 /*
 Property: inTime

 Description:
 Calculated running time of the TimeOut instance

 Datatype:
 Number

 Access:
 [Private]

 */
 private var inTime : Number;
 /*
 Property: timerEngine

 Description:
 Temporary movieclip created to run the timer

 Datatype:
 MovieClip

 Access:
 [Private]

 */
 private var timerEngine : MovieClip;
 /*
 Property: startTime

 Description:
 Calculated start time of the class instance

 Datatype:
 Number

 Access:
 [Private]

 */
 private var startTime : Number;
 /*
 Property: endTime

 Description:
 Calculated end time of the class instance

 Datatype:
 Number

 Access:
 [Private]

 */
 private var endTime : Number;
 /*
 Function: onTimeOut

 Description:
 The onTimeOut function runs the function supplied to the TimeOut instance, and then cleans up the timerEngine.

 Access:
 [Private]

 */
 private function onTimeOut ()
 {
  exFunction.apply (exObj, exArgs);
  timerEngine.onEnterFrame = null;
  timerEngine.removeMovieClip ();
  timerEngine = null;
 }
 /*
 Function: TimeOut

 Description:
 Setup the timer and provide the callback object, function and arguments.

 Access:
 [Public]

 Parameters:
 inClip - [MovieClip] Timeline clip to attach the timer engine.
 inSeconds - [Number] Number of seconds to wait before timeout
 inObj - [Object] callback object
 inFunction - [Function] callback function on object
 args - [Array] arguments to pass to the callback function

 */
 public function TimeOut (inClip : MovieClip, inSeconds : Number, inObj : Object, inFunction : Function, args : Array)
 {
  exObj = inObj;
  exFunction = inFunction;
  exArgs = args;
  inTime = inSeconds * 1000;
  startTime = getTimer ();
  endTime = startTime + inTime;
  //
  var _instance = this;
  //
  timerEngine = inClip.createEmptyMovieClip ("timerEngine" + getTimer () , 1600);
  //
  timerEngine.onEnterFrame = function ()
  {
   if (getTimer () >= _instance.endTime)
   {
    _instance.onTimeOut ();
   }
  }
 }
}

SonyPSP Site...

The Sony PSP site is due to be going live next Thursday...

As a matter of fact, the Australia and NewZealand site seems to be up and running already so you can have a quick look.

Follow this link....

I posted up a few details about the site a few weeks ago here.

as2ndac - .NET C# version

I'm in the process of rewriting the NaturalDocs AutoCommenting script in C# using the .NET framework.

This gives me a chance to learn more about writing Windows applications and getting to grips with .NET. It also gives me a chance to expand the design of the AutoCommentor, which, in it's Perl form, is a bit of a hack rather than something well designed.

All the extended features of this version will probably make their way back to the perl script eventually, but the chances of a Perl/Tk version are pretty thin, it's more likely the C# version will get wrapped in the GTK library, when I get around to it.

The new features are pretty much as per the original list...

  • Block or Line comment styles
  • Load/Save config files
  • Process folders
  • Process Multiple Files
  • Recurse folders
  • Default desription, version & author
  • Custom Headings
  • Selective Commenting

Monday, August 08, 2005

Studio 8 - Announced

Very exciting day today, Macromedia Studio 8 has been announced finally.

I'll be posting up some examples to add to the flood that have been put online over the last couple of weeks

Take a look at what macromedia are saying about it...

AS2.0 AutoComment for NaturalDocs - Beta release

Click here to download the beta release of AS2.0 NaturalDocs Auto Commentor

as2ndautocomment

Full information is available here...

By the way if you can think of a better, shorter name for this tool (that's still somewhat descriptive, drop a comment...

Ingredients for self compiling SEPY

If you are a SEPY user interested in getting the source code it can prove to be a little bit tricky, I've kept a guide for compiling SEPY from CVS on the Sephiroth.it forums up-to-date for a few months, I've decided to write these instructions up here, so there's more than one place to find them.

The instructions for compiling SEPY and getting the source from CVS, which Alessandro posted originally are out of date, and I posted the updates whenever I tried to download a significant new version and create a new source tree, third party python modules are sometimes added or updated and these are often used without notice, it's up to you to make sure these are current.

Note: These instructions are Win32/XP/2000 specific.

Get Python and modules required for SEPY

The Python binaries and modules you need to compile SEPY are as follows... (current as of 8/8/2005)

(Note: Always download the latest win32 binaries of each and install before compiling Sepy.)

python 2.4
http://www.python.org

wxPython 2.6
http://www.wxpython.org/download.php

pysqlite2
http://initd.org/tracker/pysqlite

pyRXP (xml library)
http://www.reportlab.org/pyrxp.html

pyXML
http://pyxml.sourceforge.net/

pyWin32
http://starship.python.net/crew/mhammond/win32/Downloads.html

py2exe (for build binary exe)
http://starship.python.net/crew/theller/py2exe/

4suite (utilities module)
http://4suite.org/index.xhtml

psyco (optimisation module)
http://psyco.sourceforge.net/

How to get the latest SE|PY source code via CVS.

If you know you have CVS installed on your machine, create a folder called c:\SEPYCVS and open a cmd window and type (from the C:\SEPYCVS folder)

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/sepy co .

Note: The . at the end is important!

This will get you the complete current source tree.

Note: If you don't have a command line CVS client on your machine, get CVSNT ( http://www.cvsnt.org/ )

If you prefer to use a GUI CVS client Tortoise CVS is a good choice http://www.tortoisecvs.org/

TortoiseCVS Instructions

Install TortoiseCVS and restart the PC...

To checkout SEPY to your drive

  1. Create a new folder on C:\ called SEPYCVS (c:\SEPYCVS)
  2. Right click on the folder, tortoise will have given you some new options on the context menu.
  3. Select "CVS Checkout..."
  4. Enter the following into the TortoiseCVS CVSROOT entry...
     :pserver:anonymous@cvs.sourceforge.net:/cvsroot/sepy 
    (This will fill-in most of the fields on the TortoiseCVS dialog for you.)
  5. Enter a
     . 
    (full-stop / period) into the Module entry
  6. Click OK.

Tortoise will now download the latest source tree of SEPY for you. You'll find the SEPY source code in the C:\SEPYCVS\sciTE folder

You can run SEPY from the source directly:

Open a cmd window and from the c:\SEPYCVS\SciTE\ folder type

 python main.pyw 

This will run SEPY direct from python...

If you would like to build an exe from the source type...

 make_wx25_py053.bat 

You may get an error running make_wx25_py053.bat if so it's just that it is expecting a folder to be available, so if this is your first checkout of SEPY you need to create the folder... C:\SEPYCVS\bin_2.5\main

So from the C:\SEPYCVS folder...

 
 md bin_2.5
 cd bin_2.5
 md main
 cd \SEPYCVS\scite

And then try running make_wx25_py053.bat again.

If all goes to plan you will have a SEPY.exe file in the C:\SEPYCVS\bin_2.5\main folder which you can now run...

Thursday, August 04, 2005

ActionScript 2.0 NaturalDocs Auto Commentor

I've been thinking about updating G.Wygonik's JSFL AS2.0 autodocumentor for NaturalDocs for a while now. While it's very useful in theory, I personally found that pasting each AS2.0 class into the Flash ActionScript window to perform the task was pretty tedious.

I decided to recreate the functionality in Perl since it's pattern matching is more than suitable for the task and also users of NaturalDocs will already have it installed. More importantly it enables the script to be executed on the command line so it can be integrated into most other tools and allows batch control, which of course means that processing an entire class library can be done in a few seconds...

Download Beta Version

Current Functionality

AS2NDAutoComment

Presently the test version simply takes two filenames, inputFile / outputFile. Reads the inputFile, parses the code, creates the NaturalDocs compatible documentation comments and writes to the outputFile.

At the moment the following auto commenting takes place...:

Interface definitions

Only interface declarations not preceeded by a block comment are parsed.

  • interface name
  • description stub
  • extended interface
  • ToDo Stub
  • Note Stub
  • Version stub
  • Author stub

Interface method declarations

Only interface methods declarations not preceeded by a block comment are parsed.

  • method name
  • description stub
  • parameter list
    • parameter name
    • data type
    • parameter description stub
  • return type

Class definitions

Only class declarations not preceeded by a block comment are parsed.

  • class name
  • description stub
  • dynamic and intrinsic attributes are noted in the description
  • extended super class
  • implemented interfaces
  • Usage stub
  • Example stub
  • ToDo Stub
  • Note Stub
  • Version stub
  • Author stub

Class method declarations

Only class methods declarations not preceeded by a block comment are parsed. Functions declared within other methods are not parsed, also functions declared as properties and defined inline will also fail to document correctly.

E.g.

  public var testFunction:Function = function(){ // my code }
Would fail.

  • method name
  • description stub
  • member type (private, public, static)
  • parameter list
    • parameter name
    • data type
    • parameter description stub
  • return type

Class property declarations

Only class properties not preceeded by a block comment are parsed. Properties declared within methods are not parsed, also functions declared as properties and defined inline will also fail to document correctly.

E.g.

  public var testFunction:Function = function(){ // my code }
Would fail.

  • property/var name
  • description stub
  • member type (private, public, static)
  • data type

Click here for a short example class autodocumented with the script.

Planned Features...

I'm planning a few extra features as follows...

Config File - Certain global documentation parameters could be introduced via a configuration file, this will probably take the form of an XML file. At the moment I only have a few things in mind but I'm open to suggestions.
Anyway here's what I've come up with so far.

  • Default Version string
  • Default Author string
  • Default stubs for all documented items

Other features - I will be adding better filename support so that you can parse a set of files without writing an additional .bat script. This will be done when the code parsing has been tested properly and the feature set for single file parsing is stable.

GUI - Once everything else is done I may wrap the script up in a Perl/TK based GUI so that people uncomfortable with a command line can easily use the script. There's no timetable for this at the moment.

Known issues

UTF8 - UTF8 Text seems to be ok however the UTF BOM option (in SEPY) seems to cause some problems.

Multiline method definitions - When functions are defined over multiple lines the complete parameter list and return type are not found, since documentation comments will only include whatever is on the same line as the function keyword. You may be in the habit of creating multi-line parameter lists, (I was) and this will be addressed in a later version.

Beta Release

Any comments would be very greatfully appreciated. Beta release is now available

Download Here

Monday, August 01, 2005

8/8 for flash 8

So word has it that Adobe/Macromedia are to announce the new Flash version 8 on August 8th 2005.

Of course this is exciting news for the flash community and it is pretty obvious the new features will revolutionise rich media content on the web.

The main features of note are bitmap filters and effects, blur, glow, drop-shadows, movieClip -> bitmap processing (which allows for very fast visual processing compared to the current vector biased engine, and also allows far more elements on screen.)

There are a few sites out there who have created demo's for the beta version of the new Flash 8 Player, and I've played with some of the new features myself, and it really is a major upgrade in terms of the player.

I've yet to hear any details of the Flash 8 authoring environment, but with so many third party tools Macromedia have their work cut out to bring the Flash AE up to muster, particularly in the code development department.

It wouldn't be too much of a revelation to anyone who's passed by my blog before that I do my flash development work with SEPY and I've been working more and more with MTASC although so far not on any commercial projects. The options for working on with Eclipse platform are also shaping up very nicely right now, with the soon to be released FDT actionscript development plugin and the recent announcement from Macromedia that they have joined the Eclipse Foundation

I will hopefully get some free time to post up a few of my own experiments with Flash8 this week, but if you haven't already seen what it is capable of grab the beta version of the player and take a look at some of the demo's available on the net...