Friday, October 24, 2008

Flash AS3 String Prototype Extension

Problem: 
I was working on a problem where two strings looked identical but weren't.

Solution:
Because there were many variations of the string, it was possible that some converting (and integration with stage objects:textfields) may have changed the white space characters to something different. I was able to get character codes for what existed and what I wanted to replace it with, so I wrote a simple prototype extension for the String class class replaceCodes(code1, code2), and it would change the string to reflect the replacement.

The solution/function:
String.prototype.replaceCodes = function(code:uint, code2:uint):String {
    return    this.split(String.fromCharCode(code)).join(String.fromCharCode(code2));
}

Hope this helps someone.

Tuesday, October 21, 2008

Solution to loading CakePHP styles in XAMPP

After much trial and error setting up CakePHP on Xampp (or WampServer 2.0) I finally found the problem.

The Issue: After setting up the Cakephp structure in my htdocs/ folder in Xampp, I loaded the project through http://localhost/. The page would load but none of the styling set out by the cake css sheet was rendering. The book Beginning CakePHP, mentions you need to alter the site (in my case Xampp's) httpd.conf file. It suggests you change to


<Directory /dir/to/cake>
Options Indexes FollowSymLinks
AllowOverride All
</Directory>


This is fine but I wasn't sure if this reference is relative or not. After testing it with a quoted path, relative, and an absolute path. I decided it was something else.

The Solution: With more research I discovered something the book forgot to mention. This was to change another line in the httpd.conf file. There is a line for a module that needs to be uncommented (remove the # in front of it) - that line is this:


LoadModule rewrite_module modules/mod_rewrite.so

This waisted about an hour of my life and I am hoping this post will save someone else that hour. Happy programming.