Category: Flash

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”

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”

FlashDevelop 3.0.0 R5 is out and as usual it rocks. One cool thing is that it has all the AS3 classpaths setup as default, this was something you had to manually setup in prior releases. One slightly oversighted thing is with the Adobe Air classes. Whilst code completion and syntax highlighting works if you create a FlashDevelop Air 1.5 project, the same cannot be said for when you are just editing a standalone ActionScript file which is how I tend to work. I rarely use FD projects. The fix is simple. Follow the main menu: Tools->Global Classpaths, set the dropdown to AS3 and then tap the “Add Classpath” button.

Browse to the following:
C:Program FilesFlashDevelopLibraryAS3intrinsicAIR
or on 64bit systems:
C:Program Files (x86)FlashDevelopLibraryAS3intrinsicAIR

Tap ok a couple of times to close the popups and voila, you now have Air code completion and syntax highlighting. FD FTW! ?

I noticed that a project I’ve been working on ran very slowly in IE7 and IE8 compared to FF3 and Chrome. Took me a while to track it down but it seems to be wmode related. The file in question had its wmode set to “transparent” in the containing HTML document. I did a bit of digging around and stumbled across Justin Everett-Churchs WMode Woes. He knocked up a quick demo page that shows that with wmode set to “transparent” or “opaque” any setInterval calls are slowed down to the framerate. This means my fancy scrolling system stutters like a sod since it isn’t being updated fast enough. Luckily for me I can turn it off on this project. I still love the wmode parameter but now I know its limitations. It’ll still work a treat on non time sensitive animations. I’m not sure if the setInterval/wmode pitfall applies to ActionScript 3s Timer class, I’ll have to test that on the next AS3 project I’m on.