Category: Programming

The project I’m working on today allows users to type their own filenames. The actual file extension is added afterwards by my system. I needed to check that the filename itself is valid for Windows so I came up with this:

var file_name:String = ” #DOG!”£$%^&*()_+{}~@:?><|¬`-=[]#’;/.,”;

// Remove chars not allowed in Windows filename / : * ? ” < > |
file_name = file_name.replace(/[~\/:*?”<>|]/g, “”);

// Trim leading and trailing whitespace.
file_name = file_name.replace(/^s+|s+$/gs, “”);

// traces #DOG!£$%^&()_+{}@¬`-=[]#’;.,

Although it looks like crap that is still a valid file name. So then my system automatically appends the custom file extension that I’m using. I’m clearly not a regexp wizard but the above seems to work for me. Could probably combine the two but I’m not fussed for now. I got the trim regexp from the comments in this post.

Another option would of been to use the TextFields restrict property which will prevent them from typing or pasting in any of the illegal characters. In hind-site I’ll probably switch to using that as it will be less confusing for the user:

this.my_textfield.restrict = “^\\/:*?”<>|”;

So the long awaited third and final release of my Stargate Atlantis Computer Simulator is out today. I worked like a dog all this week to finish it off in time for New Years. All the files are up on sourceforge now and the new site has been updated. Might do some more work in the future but for now I’m closing this chapter of my life.

Project Started: Tuesday 9th November 2004 23:44
Project Completed: Saturday 1st January 2011 08:32
Over 20,007 Lines of code.

Keep the lights on. I’ll be back.

So I started work on my first two Facebook applications this week. They are both Flash Christmas games I’m making for Creative Lynx Ltd. They designed and planned them and I’m putting the mechanics into place. When we started testing both the apps certain people where getting an error message popping up in their virus scanners:

Error: Permission denied for <[Server Path Edited Out]> (document.domain has not been set) to call method Location.toString on <[Server Path Edited Out]> (document.domain=<[Server Path Edited Out]>).

Took a while of searching before I got to the solution. It seems to be down to the crossdomain.xml file we’re using on the server. The whole thing including the solution is written about here on Perone’s Programming Pad. In case the page ever goes down I’m making a copy of the before and after XML files that are used to sort this out.

Here’s the XML file as it stood when we were having the problem:

<site-control permitted-cross-domain-policies="all" />
<allow-access-from domain="*" />

Here’s the XML file that fixes the problem:

<site-control permitted-cross-domain-policies="all" />
<allow-access-from domain="*" />
<allow-http-request-headers-from domain="*" headers="*" />

He talks about it showing up in Firefox’s error console. I’m guessing that Trend Antivirus is keeping an eye on the error console and flagging it up due to that. All the people that reported the problem work in the same office and have a network install of Trend i.e. they are all using the same version.

I use Flash CS5 and FlashDevelop. Never got into the Flex Eclipse malarky. Don’t really have the chance since all my clients use the Flash IDE. I like the Flash IDE as it’s convenient for quick graphical mock ups whilst at the same time allowing me to incorporate complex code written externally with FlashDevelop.

So now I’ve justified why I do what I do why am I writing this? Well sometimes there are things in Flex that the Flash IDE can’t do on it’s own. Luckily most of the Flex classes are just that, classes. I’ve found that the majority of the time you can use them in Flash IDE based projects with no problems. Occasionally I have run into walls where certain Flex SWC files are needed and that’s when you’re in real trouble since the Flash IDE chokes when it tries to load those. Luckily the Flex SOAP loading classes don’t fall into that area and are actually quite easy to use.

Continue reading “SOAP Web Service With Flash CS5 And The Flex SDK”

b2evolution uses a base tag to help with its template system. This is fine in modern browsers but depending on how the base tag is written IE6 may refuse to show the site at all, even going to the point of giving the user a popup warning dialogue. The fix is quite simple and I’ve implemented it in the past for both Joomla and CMS Made Simple. Now it’s time for the b2evolution version.

Continue reading “b2evolution Base Tag Issue”

I’m a big fan of this free DX managed wrapped called SlimDX. I used to use Managed DX but MS abandoned that which meant I was limited to DirectX version 9. SlimDX makes it possible to still use C# but also to have access to the latest DX10 and DX11 classes. The official releases of SlimDX are good but the SVN repository has the very latest changes to it. That just gives you access to the source, you still have to build your own dll to include in your SlimDX projects. I figured that some people may have trouble with this so I thought I’d write this simple guide.

Continue reading “Building your own SlimDX binary from SVN”

Hit a snag with an Air project I’m working on tonight. Got right to the end of the last set of requested changes and then started getting the error: Error #3013: File or directory is in use. It occurs with both new files and old files I’m replacing. Took me a while to suss it out but I now have a fix that works a treat.

Continue reading “ActionScript 3 – Error #3013: File or directory is in use.”

I’ve been using the new 3D functionality in Flash Player 10 and got this error earlier today:

1046: Type was not found or was not a compile-time constant: Vector3D

Quote boggling since the docs say it’s a global class as long as you have the publish settings player version set to 10. Took me a while to work it out. If this happens to you then add this at the top of your class:

import flash.geom.*;

A while ago I wrote this post about how to get Joomla working with swfobject due to the base tag issue (swfobject FAQ Point #4). At some point Joomla has had what seems like a major rewrite and I found after a recent upgrade to 2.4.6 that the base tag issue is back again. To tell the truth I wasn’t that happy with my last attempt but I also switched to using CMS Made Simpler instead of Joomla for most projects so haven’t had the chance to revisit it. Seems like now is the time. The fix is simple and is based on one that I wrote for CMS Made Simple which in turn is based on one that someone wrote for Drupal.

Continue reading “Joomla and SWFObject IE6 Base Tag Issue Revisited”

I started using Zinc when it was 2.5, it was buggy and on more than one occasion caused me some severe grievences. A nice one was when I had a presentation that had to store data in a MySQL database. Nothing complex but the presentation itself was supposed to be potentially viewed by up to 50,000 people. So what was the problem? Somehow Zinc reached version 2.5 and no one had noticed that it’s MySQL classes “Connect” function didn’t actually connect to the database. I was the lucky camper to find that one out. MDM didn’t reply to my emails so I was left to ditch Zinc and write my own Flash wrapper to handle the comms. Since several other applications were Zinc based we were kind of stuck with it. They eventually nailed all the bugs that I’d run into which was great, then we upgraded all our machines to the Vista OS. Lo and behold, Zinc 2.5 consistantly bombed out, totally not Vista friendly. So much so they actually released Zinc version 3. I knew I should of learnt my lesson.

Continue reading “Zinc 3 aka Total Waste Of Money”