AS3 particle-generator with Flex

http://www.codeodyssey.se/upload/resource/blog/particle-generator.png

Been playing around a bit with the new Adobe software Flex and I like it a lot. I have not used it that much yet but I realize that the possibilities are enormous. For a coder like me, it's a great relief to be able to use ActionScript 3.0 directly in Flex. Without the timeline and graphic interface that is such a prominent part of the normal Flash software.

Michael Battle is a flash developer who recently started to play around with AS3. He shared the source code of a particle generator and I had a go with it in Flex. I have only changed the parameters a bit and used other colors. As you can see from his experiments there are a great improvement in performance in AS3 compared to earlier versions.

Instructions
Click and drag on the green area (flash 9 requred)

 

By Jesper Lind

Create Flex-apps with online compiler

Flex is really a cool concept that makes development of flash-applications a lot easier. If you wanna se what it's all about before buying the software, there is a online compiler avalible.

Start from scratch and write MXML- and ActionScript-cod, or start with the examples. When you are ready there are a button to get the code emailed to you directly. Below there's an exampel of an RSS-reader that I made.

Bear in mind that you can't enter any RSS-feed because of the sequrity settings in the flash-player. And for some reason my feed on the english version wouldn't work, so the app loads my swedish feed.

 

 

By Jesper Lind

Database design for tagging

Social bookmarking is everywhere these days. If your're at home building the next amazing del.icio.us- or digg-clone it's important you plan the design of the database carefully. Philipp Keller shows a few variations on the post "Tags: Database schemas" and gets an enormous response in the comments.

Also read "Explaining and Showing Broad and Narrow Folksonomies" by Thomas Vander Wal (the man who coined "folksonomy"). Interesting reading about "broad" and "narrow" ways of user-tagging.

By Jesper Lind

Beautiful URL:s with ASP.NET (we're not there yet)

Some time ago I wrote about how to do URL rewrite with ASP.NET (and about the problems that are involved). Many developers has tried to tackle the problem and I will not go to ddep into the technical stuff this time. I will how ever save a few new links I found on the subject.

First an article that isn't related to ASP.NET but shows how well-designed urls should look like.

Then an link to an Wiki completely dedicated to well designed urls, where you can read "ASP.NET - Well Designed Urls Wiki".

My conclusion is that it's probably smartest to wait until IIS 7 is released. Unfortunatly it doen't seems like we will get this web server for Windows 2003. We will probably have to wait for the new Longhorn server.

IIS 7.0 will have much better support for URL-rewrite as you can read on Scott Guthrie's blog:

Several people have asked why the built-in URL Mapper in ASP.NET 2.0 doesn't support regular expressions. There were actually a few reasons for this -- one of the big ones being that just about the time we were about to consider adding it my team started also working on IIS7. We realized that a full-featured version would want/need to take advantage of some of the new features in IIS7 as well as the support all content types (in particular -- images and directories). So we postponed making it feature rich until a future version.

I am rather happy that I havn't started to try to rewrite URLs with IIS 6 yet, especially when I read reports as "Making URL rewriting on IIS 7 work like IIS 6".

The question is if one really can wait. To have nicely formatted URLs is really tempting, especially from an SEO-perspective. But if you are going to use one of this tecniques just bear in mind that you might have to redo everything once IIS 7 is released.

If you want to have some thought from someone who has started using URL-rewrite with IIS 7 on Vista, you can read Dennis blog.

By Jesper Lind

Christmas games x 6

http://www.codeodyssey.se/upload/resource/blog/christmas-games-6.jpg

I've collected a few links for Christmas games to play with in the holidays. Merry Christmas!

1. Mission in snowdrift land - game from Nintendo where you control a snowman.

2. Snowline - ride a toboggan and collect Christmas gifts.

3. Busy Santa - help Santa to build toys.

4. Winterbells - jump on bells.

5. Snowdays - cut your own snowflakes.

6. Make-a-flake - more snowflakes.

Bonus: Sober Santa has been around for some years, but give it a go if you haven't seen it. The too-drunk-Santa is rather amusing.

By Jesper Lind

A class that generates passwords

This is an example of a class that generates passwords. I have used it for so long that i forgot where I found it originally. If you recognize the code, please let me know the origin and I will add a reference.
using System; using System.Data; using System.Configuration; using System.Web; using System.Text; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; /// /// Summary description for PasswordGenerator /// public class PasswordGenerator : Page { private char[] characterArray; private Int32 passwordLength = 10; Random randNum = new Random(); public PasswordGenerator() { characterArray = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray(); } private char GetRandomCharacter() { return this.characterArray[(int)((this.characterArray.GetUpperBound(0) + 1) * randNum.NextDouble())]; } public string Generate() { StringBuilder sb = new StringBuilder(); sb.Capacity = passwordLength; for (int count = 0; count <= passwordLength - 1; count++) { sb.Append(GetRandomCharacter()); } if ((sb != null)) { return sb.ToString(); } return string.Empty; } }
By Jesper Lind

Japanese artist delivers masterpieces on Roxik.com

http://www.codeodyssey.se/upload/resource/blog/roxik.jpg

I started to subscribe to the blog RockOnFlash a while ago where John Grden writes about rock, drums, Flash and more. Recently he wrote a post about the japanese artist Masayuki Kido - who presents his work on Roxik.com.

I can really recommend a visit to the site where you are greeted by an animated self portrait of the artist in 3D. You can pull the face with the mouse and when released it shakes for a while and makes a funny face.

The same artist has also created an absolutely fantastic animation where people are flying around in a storm. Really advanced stuff and very beautiful.

And it doesn't end there, also check out the "pictaps" application where you can draw your own figures which dances in 3D.

By Jesper Lind

Troubleshooting: A potentially dangerous Request.Form value was detected from the client

This is an error which is caused by posting html-code in a textbox. The text doesn't need to contain valid HTML, just anything with opening and closing angled brackets ("<...>").

The complete error:

Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ctl00$mainContentPH$fvFaq$tbFaqBody_sv-SE="...the link <a href="http://www....").

Solution
There are two ways to disable request validation.

1. Turn it off in the Web.config file

<system.web>
<pages ValidateRequest="false"/>
</system.web>

2. Turn it off on the page it self

<%@ Page ValidateRequest="false" ... %>

A warning for injection
The validation is there for a reason. If you turn it off, visitors can post code like this, and that's not wanted in most cases.

alert('I am posting some dangerous code')

More info on the web site of Brian Cryer.

By Jesper Lind