Tutorial: Setting up WordPress to communicate with Flash via XML

This following bit of code should get you up and running with a simple way of sharing data from your wordpress blog with a flash object. Creating the XML file is a bit of a hastle, since you can’t output XML directly from a wordpress template file to flash. Instead you have to use php’s fopen function to save your xml file to be accessed separately through your flash object.

The PHP

{code type=php}

get_results($query, OBJECT);

$xml .= “n”;
$xml .= “Your Data Goes Here”;

// save your xml file in your theme directory
$path = ‘wp-content/themes/themename/output.xml’;
$file= fopen(“$path”, “w”);
fwrite($file, $xml);
fclose($file);
?>
{/code}

The HTML & Javascript

{code type=html}

Flash Not Detected

// <![CDATA[
var so = new SWFObject('/flashobject.swf’, ‘website’, ‘600’, ‘270’, ‘9’);
so.useExpressInstall(‘/expressinstall.swf’);
so.addParam(‘menu’, ‘false’);
so.addParam(‘wmode’, ‘transparent’);
so.addVariable(“xmlVar”, ‘/output.xml’);
so.write(‘flashcontent’);
// ]]>

{/code}

Setting Up Facebook Connect for WordPress

These steps are needed to prepare your wordpress blog for facebook connect integration using the WP-FBConnect Plugin. The plugin is documented here and you can download it here. The implementation is pretty simple, but there are some caveats as follows.

Step 1:

Add the language attributes wp function to your header(s). The plugin will add the following lanuage attribute for you “xmlns:fb=”http://www.facebook.com/2008/fbml&#8221;.

{code type=php}

<html xmlns=”http://www.w3.org/1999/xhtml&#8221;
<?php language_attributes(); ?>>

{/code}

Continue reading

Mobile ‘Apps’ with HTML, CSS & Javascript

I stumbled across this article that has some good tips for developing rich web based mobile apps for the iPhone and other devices using just html,css and javascript. These tools look like they could be pretty useful if you want to ‘mobilize’ the content of your existing website but don’t want to go through the hastle of developing a new app for each new platform in C or Java.

What is PhoneGap?

PhoneGap is a development tool that allows web developers to take advantage of the core features in the iPhone, Android, and Blackberry SDK using JavaScript.

iui

Based on Joe Hewitt‘s iPhone navigation work, iui has the following features:

* Create Navigational Menus and iPhone interfaces from standard HTML

* Use or knowledge of JavaScript is not required to create basic iPhone pages

* Ability to handle phone orientation changes

* Provide a more “iPhone-like” experience to Web apps (on or off the iPhone)

While the ‘apps’ that you craft with these tools won’t be quite as fully featured as those that are native to the phone’s OS…they are certainly a great time saver and are relatively simple to update and maintain.

Displaying External Images in Flex

Recently I had to find a method to include external images in a flex project.
After much searching I found the following which was the simplest:

First, you must check the domain you are pulling images from to make sure
that they allow access in their crossdomain.xml file:

<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>

Now the code…

	[Bindable]
	var loaderContext:LoaderContext;

	private function imageInit():void {
    	 loaderContext = new LoaderContext();
     	 loaderContext.checkPolicyFile = true;
	}

and the mxml for the image…

<mx:Image source="{your-picture-here}"
initialize="imageInit()" loaderContext="{loaderContext}"/>