Monthly Archive for February, 2006

ActionScript3 preprocessing

If you are familiar with C you know what a preprocessor is. Otherwise you may want to take a look at the blog of Mike Chambers and come back after reading his article on using a preprocessor with ActionScript.

If you read the article of Chambers or know about preprocessors in general you may know that you can not edit and compile the same file that you send through a preprocessor. Chambers does not have this problem because he uses a commandline everytime he compiles his files.

You could have one directory called \bin\ and one \source\ but that is very long-winded. What I need are the benefits of a preprocessor but I just do not want to feel that there is a preprocessor workin in the background.

Therefore I wrote two little applications. Let me explain how it works. My first idea was to substitute the MXMLC (aka Macromedia Flex Compiler). The problem is that the Compiler is deep integrated in the Flex framework and since I do not know anything about Eclipse and that framework stuff I had to throw that idea away.

The next solution that crossed my mind was to have two seperate applications. The first should create a backup of the code and then run the preprocessor. Then the Flex Builder could do his work. After that is done the second application should restore the original sourcecodes. Sounds good – works great.

How to?
First of all you need the cpp preprocessor that Chambers talks about. Google will be your friend. Then download my little package called as3pp. Now follow theese instructions:

Step 05
1.) Unzip to a location that fits into your aesthetic well-being.
2.) Start Flex Builder
3.) Create a new project
4.) Open Project->Properties and switch “Builders”
5.) Create a new Builder and call it “Preprocessor”. The settings should look like in the picture.
On the “Refresh” tab make sure that the following options are checked:
- Refresh resources upon completion.
- The selected source
- Recursively include sub-folders
On the “Build Options” tab make sure that the following options are checked:
- After a “Clean”
- During manual builds
- During auto bulds
- During a “Clean”
Done.
6.) Create another new builder and call it “File Restore”. The settings should be the same that you used for the preprocessor
7.) Arrange the builders in this order

You are done. Make sure to uncheck the “Build Automatically” option in the Project menu. You are done. The preprocessor works for me fine and I will never miss it anymore :o)

Please leave a comment about bugs etc. The as3pp tools should work with win9x/nt systems.

flIRC – next version with Flex2 Beta 1

Some days after the first Flex2 Alpha has been released I presented flIRC as my first experiment with the new Actionscript 3.0 features and Flex2. Now there is the Flex2 Beta and old projects do not work with the new version any longer. So I thought it could be nice if I rewrite the well-liked irc client. The old version was very creepy. There were only some events supported and no private messages.

This new release of flIRC features public and private chats (channels and querys). There are also more than 75 IRC-events supported. This is still not the whole protocol but a try to enable most common features. Here is a list of what I have implemented and how.

IRC:

  • Most RAW events are supported (still not all)
  • JOIN, QUIT, PART, KICK, TOPIC, MODE, NICK, etc.
  • Supporting standart channel modes
  • CTCP
  • Op, HalfOp, Voice and regular users

Flex2/GUI:

  • Making use of regular expressions
  • flIRC makes use of the new event system (every event that comes from IRC gets transferred into an individual AS3 event)
  • Components and simple effects
  • Using the new Socket class for example
  • ContextMenus (not fully implemented)
  • Multi-Tab view

It is also nice that I can skin the client in different ways using stylesheets. This is also implemented but I focused on the code and not on the view so there is the default style. If you want to send me a nice stylesheet I could use it for flIRC :) Imagine the scenario. People who run a dating site for example could setup an irc server on their shell and install flIRC. All they have to do is to skin the application and maybe the text-messages.

There are still two problems I had to overcome. The first is still the security of Flash. It is not possible to connect to an irc server directly since it is not allowed. I use a proxy on my shell to get around this problem. The next is TextAreas. TextAreas have sometimes a strange behaviour. If you use htmlText in a TextArea only milliseconds after the TextArea has been created it will not display. But never the less this was not a big problem since there is the Timer class.

What is still missing? A lot of raw events. Some bugs. A nice GUI. More channel modes.
Note: This is only a demo version. Not all features of the IRC protocol may work properly.

Links:

Problem with AS3 Experiments

Just a short piece of news here. All Actionscript 3 examples do not work any longer with the Flex2 Builder Beta.

I have to update them and will post a new list with links to examples. This will be maybe on next thursday because projects are killing me.

I am sorry for the “downtime” but stay tuned.

Flex 2.0 Beta 1 has been released

You are now able to download the Flex 2.0 Beta 1 from Adobe labs. There are some instructions on the installation. You have do uninstall Flex2 Builder totally from the system and delete the project definitions.

I do not have the time to test it out. What a shame. More to come on the weekend. Maybe an updated flIRC.

Links: