E4X – Updating multiple node values

December 27, 2009 · Posted in Flash, XML · Comment 

Something that is often required when processing XML documents is to update a bunch of nodes that are spread throughout the document.

Consider the following XML:

<gallery base="images/projects/">
	<project id="1" >
		<item type="image" thumb="image1.jpg">
			<path>l_image1.jpg</path>
		</item>
	</project>
	<project id="2">
		<item type="image" thumb="image2.jpg">
			<path>l_image2.jpg</path>
		</item>
	</project>
	<project id="3">
		<item type="image" thumb="image1.jpg">
			<path>l_image1.jpg</path>
		</item>
		<item type="image" thumb="image3.jpg">
			<path>l_image3.jpg</path>
		</item>
		<item type="image" thumb="image4.jpg">
			<path>l_image4.jpg</path>
		</item>
		<item type="image" thumb="image5.jpg">
			<path>l_image5.jpg</path>
		</item>
	</project>
</gallery>

Lets assume that we need to load the thumbnails of each item specified by the thumb attribute. I often use a base path for the images. It make a lot of sense to include it at document level rather than repeating it in each property value. Doing so reduces file size and also makes path updates quick and painless.

Once the XML document is loaded, the thumb path can be updated with a single line of code:

galleryXML..item.(@thumb = baseUrl + @thumb);

where baseUrl variable holds the base path. Or we can directly substitute with the value of base property like so:

galleryXML..item.(@thumb = galleryXML.@base.toString() + @thumb);

A trace of galleryXML will show that the path of each thumb attribute is prefixed with the base path.

Installing Apache + MySQL + PHP on Windows 7 64Bit

December 16, 2009 · Posted in General · Comment 

The process is pretty straight-forward, except for a few bumps along the way. The majority of problems were caused by the Access Control functionality of Win 7. Make sure your text editor is running with admin rights. Without which you’ll not be able to save any edits to the config files.

The first issue was during Apache (2.2.14-x86) install; kept getting the following error:

Errors reported here must be corrected before the service can be started.
httpd.exe: Could not reliably determine the server's fully qualified domain name ,
using 192.168.1.3 for ServerName (OS 10048)
Only one usage of each socket address (protocol/network address/port) is normally permitted.
: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available,
shutting down Unable to open logs
Note the errors or messages above, and press the key to exit. 24...

After 10mins of trying to figure out the problem with no success, did a search and found that this was due to port 80 being used by another program – typically Skype! Which made sense as I had Skype running. Once I quit Skype and restarted Apache, everything started up smoothly.

Next, I wanted to get my virtual hosts setup. I like to keep my virtuals in their own separate file – 1 file per host. This is pretty easy to setup – just direct Apache to load up additional conf files with an “Include” directive.

NOTE: There’s a sample virtual host config file included with the Apache install in “conf/extra” folder, which may be modified to your needs.

Open the default httpd.conf and add the following to the end of it.

# Setup virtual hosts
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:/webapps/_root"
<Directory />
        Order Allow,Deny
        Allow from all
</Directory>
</VirtualHost>
Include "D:/webapps/_virtuals/*.conf"

Next, create blog.conf file with the following content. Make sure to give it a meaningful name – something like blog.sprit3.conf, so that it can be located easily. Save the file in the _virtuals folder.

<VirtualHost *:80>
ServerName blog.sprit3.net
DocumentRoot "D:/webapps/www/blog.sprit3"
<Directory />
        Order Allow,Deny
        Allow from all
</Directory>
</VirtualHost>

By default Apache will deny any requests to the virtual folders unless allowed explicitly. Hence the <Directory> tag.

Save this in the _virtuals folder and restart Apache. Verify if virtuals are running properly by entering “httpd -S” via the command prompt.

Next step is to add the virtual host address to the local host file so that any requests to blog.sprit3.net will be directed to my localhost instead of the live site. Windows hosts file is located at %SystemRoot%/system32/drivers/etc folder.

That should get the virtual folder running and all the web apps nicely organised!

Google translate – simply amazing!

December 14, 2009 · Posted in General · Comment 

Google Translate

…one step closer to a wearable “Universal Translator”!

Offline language reference in Flash CS4

November 15, 2009 · Posted in Flash · Comment 

If, like me, you’re frustrated with CS4 language reference going to the online version, there is a part solution available which Jon has written about a while back. Basically what it does is instead of going online, it opens the local copy of help inside the browser – which is much faster for quick look-ups.

To do this; from the top menu, open Window > Extensions > Connections. Then click on the down arrow at top right of the panel and select “Offline options.

I hope Adobe will provide a help panel similar to Flex builder in the upcoming version…

Meerkat is calling!

September 4, 2009 · Posted in Coolspot · 1 Comment 

 

Next Page »