<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Monkey Magician</title>
	<atom:link href="http://www.monkeymagician.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.monkeymagician.co.uk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 26 Feb 2010 12:10:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTML Canvas, drawImage and onload</title>
		<link>http://www.monkeymagician.co.uk/2010/02/26/html-canvas-onload/</link>
		<comments>http://www.monkeymagician.co.uk/2010/02/26/html-canvas-onload/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 10:56:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[load]]></category>
		<category><![CDATA[ready]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/?p=39</guid>
		<description><![CDATA[I recently had a play with the HTML &#60;canvas&#62; element as an alternative to creating a simple animated UI in Flex or Flash. When it came to using the drawImage function I hit upon a strange problem. 
The drawImage method of the canvas context is used to write image data onto the canvas from an [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a play with the HTML &lt;canvas&gt; element as an alternative to creating a simple animated UI in Flex or Flash. When it came to using the drawImage function I hit upon a strange problem. <span id="more-39"></span></p>
<p>The drawImage method of the canvas context is used to write image data onto the canvas from an HTMLImageElement, from another canvas or from an HTML &lt;video&gt; element. I was attempting to draw the contents of an &lt;img&gt; tag into the canvas but almost every page load was getting the following error from Firefox:</p>
<blockquote><p>uncaught exception: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIDOMCanvasRenderingContext2D.drawImage]&#8220;  nsresult: &#8220;0&#215;80040111 (NS_ERROR_NOT_AVAILABLE)&#8221;  location: &#8220;JS frame :: http://localhost/canvas/js/interface.js :: anonymous :: line 114&#8243;  data: no]</p></blockquote>
<p>After much confusion I realised that I was setting up the canvas in a DOM ready event handler so it made sense that if the image hadn&#8217;t also loaded, its data wouldn&#8217;t be available to be drawn. Switching to the onload event cured the issues.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2010/02/26/html-canvas-onload/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strange URLs when using the Flex SWFLoader</title>
		<link>http://www.monkeymagician.co.uk/2009/08/24/strange-urls-flex-loader/</link>
		<comments>http://www.monkeymagician.co.uk/2009/08/24/strange-urls-flex-loader/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 08:29:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/?p=30</guid>
		<description><![CDATA[I was recently working on a Flex application that had to import a third-party SWF and use its API. Conversely, it needed to access the stage and add children. It threw up an interesting problem with strange import URLs that I finally solved.
I started with the following:
&#60;mx:SWFloader source="http://www.example.com/external.swf" complete="loadComplete(event)" /&#62;
The first security sandbox error was [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently working on a Flex application that had to import a third-party SWF and use its API. Conversely, it needed to access the stage and add children. It threw up an interesting problem with strange import URLs that I finally solved.<span id="more-30"></span></p>
<p>I started with the following:</p>
<pre class="code">&lt;mx:SWFloader source="http://www.example.com/external.swf" complete="loadComplete(event)" /&gt;</pre>
<p>The first security sandbox error was about external.swf not being able to access the stage property. A quick view of the SWFLoader documentation lead to adding the trustContent property:</p>
<pre class="code">&lt;mx:SWFloader source="http://www.example.com/external.swf" complete="loadComplete(event)" trustContent="true" /&gt;</pre>
<p>After switching debugging to a local server on http://flex so that it wasn&#8217;t running in the local security sandbox, the stage error went away.</p>
<p>However, I ended up with a very strange URL not found error along the lines of &#8216;Error #2035: URL Not Found. URL: http://flex/[[IMPORT]]/www.example.com/external2.swf&#8217;. Looked like the third-party SWF was in turn trying to load a further SWF. After discussions with the developers, it turned out they were loading another SWF from the same location by using the LoaderInfo.url property.</p>
<p>Digging around in the SWFLoader source, reading lots of documentation about Flash&#8217;s security model and lots of unsuccessful searching lead me to what appears to be an undocumented feature. When the external content was imported into my application&#8217;s SecurityDomain the loader URL is changed to the one shown above with [[import]] in it. This means that their URL building was failing to produce the correct URL.</p>
<p>The solution was to remove the trustContent property so that the content wasn&#8217;t loaded into the security domain. Initially the stage error came back but by adding Security.allowDomain(&#8216;www.example.com&#8217;) allowed the loaded SWF access to the stage. The same could have been achieved with a crossdomain.xml, I would have thought.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2009/08/24/strange-urls-flex-loader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>System Tray Icon and Menu for an Adobe Flex AIR Application</title>
		<link>http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/</link>
		<comments>http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 19:20:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Adobe AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[adobe]]></category>
		<category><![CDATA[air]]></category>
		<category><![CDATA[dock]]></category>
		<category><![CDATA[icon]]></category>
		<category><![CDATA[system tray]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/</guid>
		<description><![CDATA[Adobe AIR allows you to set up a system tray icon and context menu for your application. In true AIR &#38; Flex style, this is surprisingly simple to achieve and doesn&#8217;t even require a .ico file.
Creating the System Tray Icon
Within the WindowedApplication we can embed a graphic to be used as the icon. I&#8217;m using [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe AIR allows you to set up a system tray icon and context menu for your application. In true AIR &amp; Flex style, this is surprisingly simple to achieve and doesn&#8217;t even require a .ico file.<span id="more-29"></span></p>
<h3>Creating the System Tray Icon</h3>
<p>Within the WindowedApplication we can embed a graphic to be used as the icon. I&#8217;m using a 16 x 16 PNG with full alpha transparency.</p>
<pre class="code">[Embed(source="icons/tray.png")]

private var TrayIcon:Class;</pre>
<p>By attaching a handler to the initialize event, an instance of the embedded image is created (cast to a Bitmap) and the bitmap data extracted. This data can then be assigned to the array of icons for the application. I&#8217;m also setting the tooltip text. This code is wrapped inside a check that the system support system tray icons.</p>
<pre class="code">if (NativeApplication.supportsSystemTrayIcon) {
    var trayIcon:BitmapData = Bitmap(new TrayIcon()).bitmapData;
    SystemTrayIcon(nativeApplication.icon).bitmaps = [trayIcon];
    SystemTrayIcon(nativeApplication.icon).tooltip = 'This text will appear when hovering over the icon';
}</pre>
<p>The icon also supports event handlers for various ScreenMouseEvent types, meaning you can handle clicks, right clicks and so on, depending on your requirements.</p>
<h3>Creating a Context Menu</h3>
<p>The context menu for the tray icon is created as a standard NativeMenu (with a number of NativeMenuItem items) and then assigned as the menu for the icon. The sample below defined a menu with an exit option which is handled by a separate handler function.</p>
<pre class="code">var menu:NativeMenu = new NativeMenu();

var exitMenuItem:NativeMenuItem = new NativeMenuItem("Exit");
exitMenuItem.addEventListener(Event.SELECT, exitApplication);
menu.addItem(exitMenuItem);

SystemTrayIcon(nativeApplication.icon).menu = menu;</pre>
<p>The menu will now appear on a right click on the tray icon, there is no need to explicitly wire this interaction together.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2009/04/22/system-tray-icon-and-menu-for-an-adobe-flex-air-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SliceHost Setup</title>
		<link>http://www.monkeymagician.co.uk/2009/02/12/slicehost-setup/</link>
		<comments>http://www.monkeymagician.co.uk/2009/02/12/slicehost-setup/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 12:00:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[gutsy]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/2009/02/12/slicehost-setup/</guid>
		<description><![CDATA[After being a customer of various web hosting providers over the years, I finally decided to put the knowledge of Linux I have gained to good use and set up my own hosting on SliceHost using Ubuntu Gutsty (7.10). I felt I found some good articles and learnt alot that I would like to share.

SliceHost [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.monkeymagician.co.uk/wp-content/uploads/2009/02/slicehost.thumbnail.gif" alt="SliceHost Logo" class="border" style="margin: 0pt 0pt 15px 15px; padding: 5px; float: right" />After being a customer of various web hosting providers over the years, I finally decided to put the knowledge of Linux I have gained to good use and set up my own hosting on <a href="http://www.slicehost.com" title="SliceHost" rel="external">SliceHost</a> using <a href="http://www.ubuntu.com" rel="external">Ubuntu</a> Gutsty (7.10). I felt I found some good articles and learnt alot that I would like to share.<br />
<span id="more-8"></span></p>
<p>SliceHost define themselves as a &#8216;hosting company for people who know there stuff&#8217; and after 2 years of building and maintaining a Linux server as part of my job I figured I either knew my stuff or could at least pretend I did. At the time, their popularity was such that you had to wait until they could meet your requirements, the wait dependent on the slice size and pre-payment term you wanted. It looks like customers now get to build their slice immediately.</p>
<p>On the plus side, I used the weeks to decide which Linux distro to use on my slice. After considering Fedora 8 in the vain hope it would be similar to RedHat, I eventually opted for Ubuntu 7.10 (aka Gutsy Gibbon) after noting that there were more articles on the <a href="http://wiki.slicehost.com/doku.php">SliceWiki</a> than for other distros.</p>
<h3>Security</h3>
<p>Once I built the slice there were a few basic security tasks to get out of the way before going any further. The <a href="http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-1">getting started article</a> was a good place to start and covers all the security that in the past my hosting company would have done all this for me. So I changed the root password, created a new user and gave them sudo privilege, turned off root ssh access and as an extra security I also changed the ssh port to something memorable rather than 22. The article also covers using iptables as a firewall so I followed it to the letter, not having much previous experience with iptables.</p>
<p>The <a href="http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-2">second part</a> of the guide goes into more detail than I felt I needed so I limited myself to updating sources and upgrading the system as well as installing the build essentials. At the time I thought I would be building Apache, PHP and MySQL from source as I have had to do on Red Hat before now. How wrong I was&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2009/02/12/slicehost-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Default Event Handlers in MooTools 1.2 Classes</title>
		<link>http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/</link>
		<comments>http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 14:33:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[options]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/</guid>
		<description><![CDATA[I recently started converting some UI components I created in MooTools 1.1 into 1.2 versions to use on a new project. For a point release, I&#8217;m surprised how different a lot of the MooTools syntax is in the latest version. One thing that took a bit of getting used to was how inheritance has changed, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started converting some UI components I created in MooTools 1.1 into 1.2 versions to use on a new project. For a point release, I&#8217;m surprised how different a lot of the MooTools syntax is in the latest version. One thing that took a bit of getting used to was how inheritance has changed, and the knock on effects when using Options and Effects in my classes.<span id="more-12"></span></p>
<p>In the MooTools 1.1 version I had a base class, &#8216;Widget&#8217; which I would extend as below:</p>
<p class="code">var DialogBox = Widget.extend({ &#8230; });</p>
<p>Widget implements both Options and Events which allowed me to create a set of events the widget can fire, handlers for which can be added through options, as such:</p>
<pre class="code">var DialogBox = Widget.extend({
  options : {
    onCancel : this.close.bind(this)
  }
  ...
});</pre>
<p>Because extend is a method of Widget, its &#8216;this&#8217; is the object itself and, provided there is a close method, the event handler for &#8216;cancel&#8217; is set up.</p>
<p>MooTools 1.2 introduces a new syntax for extending objects:</p>
<pre class="code">
var DialogBox = new Class({
  Extends : Widget,

  options : {
    onCancel : this.close.bind(this)
  },
  ...
});</pre>
<p>Now, the &#8216;this&#8217; is actually the window object so the cancel event is actually handled by the window.close method &#8211; not quite the functionality intended!</p>
<p>After digging around in the MooTools code, in particular the Request.HTML class, I found what appears to be the only way to default events in options. By setting the option before calling setOptions (if it isn&#8217;t already set), the event handler is correctly assigned:</p>
<pre class="code">
var DialogBox = new Class({
  Extends : Widget,

  options : {
    ...
  },

  initialize: function(options) {
    options.onCancel = options.onCancel || this.close.bind(this);
    this.setOptions(options);
  },
  ...
});</pre>
<p>The binding is now done on instantiation so the correct close method is assigned as the cancel event handler.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2008/08/31/default-events-in-mootools-12-classes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Live Javascript Validation</title>
		<link>http://www.monkeymagician.co.uk/2007/09/05/live-javascript-validation/</link>
		<comments>http://www.monkeymagician.co.uk/2007/09/05/live-javascript-validation/#comments</comments>
		<pubDate>Wed, 05 Sep 2007 14:26:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://www.monkeymagician.co.uk/?p=5</guid>
		<description><![CDATA[A colleague of mine at Vebra has been working on a very Web 2.0 update of the outdated concepts of JavaScript client-side validation, Live Validation.
Traditionally, JavaScript form validation involves calling a validate function when the onSubmit event of the form is fired, with the function returning whether or not the form validated. In most cases, [...]]]></description>
			<content:encoded><![CDATA[<p>A colleague of mine at <a href="http://www.vebra.info/" rel="external">Vebra</a> has been working on a very Web 2.0 update of the outdated concepts of JavaScript client-side validation, <a href="http://www.livevalidation.com/" rel="external">Live Validation</a>.<span id="more-5"></span></p>
<p>Traditionally, <a href="http://www.w3schools.com/js/js_form_validation.asp" rel="external">JavaScript form validation</a> involves calling a validate function when the onSubmit event of the form is fired, with the function returning whether or not the form validated. In most cases, if validation failed the user is informed; in the best cases with a highlighted field and inline message, in the worst with an alert box.</p>
<p>With recent trends in website / web application development moving towards more responsive pages and the use of Ajax to speed up user interaction, this system has been crying out for a radical update. Until now.</p>
<p><a href="http://www.livevalidation.com/" rel="external">Live Validation</a> allows a developer to hook any number of validation requirements directly onto form elements. As a user interacts with the field they are given real-time feedback as to whether their data is valid.</p>
<p><img src="http://www.monkeymagician.co.uk/wp-content/uploads/2008/01/livevalidation1.png" alt="Live Validation" class="border" /></p>
<p>The open-source library is available for download to work either with the Prototype framework or as a stand-alone version. The Prototype version integrates well with Ruby on Rails applications and the coding conventions of Live Validation will be very familiar to Rails developers but simple enough to be understood by anyone with basic JavaScript knowledge.</p>
<p>Once the library is downloaded and included on your page, adding validation couldn&#8217;t be much easier. The LiveValidation object is instantiated with an id of (or reference to) the input element and then rules added to the object. The following example validates for a required field with an id of &#8216;f1&#8242;:</p>
<p class="code">var f1 = new LiveValidation(&#8216;f1&#8242;);<br />
f1.add(Validate.Presence);</p>
<p>LiveValidation also allows chaining of rules and even the object so that it is possible to simply have a single line of code provide very powerful validation rules. The example below requires the field to be filled and to be numeric:</p>
<p class="code">new LiveValidation(&#8216;f1&#8242;).add(Validate.Presence).add(Validate.Numericality);</p>
<p>The range of validation rules doesn&#8217;t end with required fields and numbers, Live Validation also covers regular expression pattern matching, numeric ranges, length ranges and inclusion / exclusion, amongst others.</p>
<p>Overall, Live Validation&#8217;s powerful features, simplicity of use and extensive on-line documentation, combined with it&#8217;s graceful degradation and real-time user interaction add up to provide a fantastic replacement for an ageing concept.</p>
<p class="update"><em>Update: Since writing the article there have been two point-releases of LiveValidation and it is now on version 1.2. Added is support for select boxes, time delayed checking and automatic onSubmit validation. Full details are available on <a href="http://www.livevalidation.com/blog" rel="external">the blog</a>.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.monkeymagician.co.uk/2007/09/05/live-javascript-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
