Blog posts

Dec 14

Dice Adobe Air application

Written: Dec 14th 2008, 23:45

Had some friends over at my place on saturday and for beer and “Navigare” (like the Monopoly Board Game only on the ocean). Unfortunately the dice was gone.. Well, creating a random thing shouldn’t be that hard on a computer, so I wrote this simple dice application.


Download Dice.air (Adobe Air Application)


Download Dice Source

Permalink for Dice Adobe Air application
Oct 11

Leaves are falling while I am coding

Written: Oct 11th 2008, 17:07

After a rather tough season with plenty of triathlon competions here in Norway. The main race where a Ironman in Kalmar the 2. of august, where I completed the 3.8 km swim, 180 bicycle leg and marathon on 10 hours and 15 minutes.

Since then my weekly training volume has dropped, and I have been spent more time on my new MacBook doing computer related stuff.

Things archived so far this fall

  • Did a revision of the code on this site (www.gersh.no) and upgraded to CakePHP 1.2.
  • Redesign my norwegian blog at www.gerhardsletten.no – not quite finished yet, think I might also need to do a rebranding.
  • Added some new open source project to www.gersh.no/projects that I have been having laying around.

Upcoming plans for this winter

  • This summer I have been included in the Norseman Extreme Triathlon Crew, with responsibility for their homepage at www.nxtri.com where we will move it over to the Ez publish platform and enhance usability.
  • Write a Adobe Air application for uploading images directly to your own server, and a PHP application to receive these files. Much as the Picasa or Flickr plugin for iPhoto, but on your own server.
  • Write a new version of WorkTimer in Adobe Air, but maybe with some new features. I have been receiving a lot of wishes via mail, and I also would like to add some “Scrum” functionality like Scrumworks.
  • With my new work at www.netmaking.no – a Ez partner here in Oslo I will probably be doing a lot of stuff in the Ez to.
  • Working on my norwegian sourdough site www.surdeig.no. A lot of people have signed up!

Guess it won’t be a lazy winter for me..

Permalink for Leaves are falling while I am coding
Jul 22

Beta invitation for Aviary Webapps

Written: Jul 22nd 2008, 22:06

 Aviary homepage

Today I recieved a beta invitation to Aviary – a collection of online applications for “image editing to typography to music to 3D to video”. By now it only seems I have access to Phoenix – a image editor and Peacook – a pattern creator.

Permalink for Beta invitation for Aviary Webapps
May 26

Partly support for Flash XML parsing in Adobe Air JavaScript

Written: May 26th 2008, 22:46

Working with both Ajax and Flash tecnologies I often miss the great support Actionscript has to the XML format.

Reading the Adobe Air for JavaScript Developer – Pocket Guide I saw some examples of using flash objects in JavaScript. Curious if I also could use the XML parser, I did some testing.

And yes, you can use the parser. But before you can parse it with window.runtime.XML you have to take it via the old window.runtime.flash.xml.XMLDocument() function. 

And unfortunately you can call any function on it i.e. XMLlist.length()

Here is the JavaScript code:

&lt;script src="js/AIRAliases.js" type="text/javascript"&gt;&lt;/script&gt;<br>&lt;script type="text/javascript"&gt;<br>	// Var that holds the data loaded<br>	var xml_doc;<br>	// The function that starts the asynchronously reading of the file<br>	function doLoad() { <br>		var file = air.File.applicationDirectory.resolvePath('rss.xml' ); <br>		stream = new air.FileStream(); <br>		stream.addEventListener( air.ProgressEvent.PROGRESS, doProgress ); <br>		stream.openAsync( file, air.FileMode.READ ); <br>	} <br>	// Eventlistener for the fileloading<br>	function doProgress( event ) { <br>		var data = stream.readMultiByte( stream.bytesAvailable, "utf-8" ); <br>		xml_doc += data;<br>		if( event.bytesLoaded == event.bytesTotal ) { <br>			stream.close();<br>			// Call the parse function when fileloading is completed<br>			parseXML();<br>		} <br>	}<br>	function parseXML() { <br>		var result = new window.runtime.flash.xml.XMLDocument();<br>		result.ignoreWhite = true;<br>		result.parseXML(xml_doc);<br>		var myXML = new window.runtime.XML(result.lastChild);<br>		alert(myXML.channel.item[2].title);<br>	}<br>&lt;/script&gt; 

Why: Today most webservices have a growing support  for JSON, but still XML is the most widely spread format. Working with XML files in Javascript can be a little troublesome, and often you want to use an external library for the parsing.

Permalink for Partly support for Flash XML parsing in Adobe Air JavaScript
May 09

Using Flex SDK on mac

Written: May 9th 2008, 14:17

Your first Flex application with TextMate

Adobe recently made Flex opensource. That mean that you don’t have to use their Flex Builder in order to make Flex-apps.

This is a quick intro in how to use Flex with Textmate on mac.

Download the Flex SDK

You can download the Flex SDK from Adobe’s site. Place it whereevery you want, but be sure to make it available in your Path:

/Users/gerhard/.bashrc

export PATH; PATH="/Developer/SDKs/air_sdk/bin/:/Developer/SDKs/flex_sdk_3/bin/:/Developer/Tools:/Developer/Applications:/usr/local/bin:/usr/local/subversion/bin:$PATH"<br>alias flex="mxmlc"

I also added a alias for the compiler, located inside the bin/ dir of the SDK.

Download the TextMate bundle for AS3 and Flex

The ActionScript 3 Bundle and the Flex Bundle can be downloaded from TextMates Repository at: http://macromates.com/svn/Bundles/trunk/Review/Bundles/ (Use the SvnX app for mac to access these). Install this and you are ready to start developing in Flex.

Mini tutorial – your first Flex-app with TextMate

Create a new file in TextMate, and name it FlexTest1.mxml:

&lt;?xml version="1.0"?&gt; <br>&lt;!-- mxml/TriggerCodeExample.mxml --&gt; <br>&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;<br>    &lt;mx:Panel title="My Application" <br>        paddingTop="10" <br>        paddingBottom="10" <br>        paddingLeft="10" <br>        paddingRight="10" <br>    &gt; <br>        &lt;mx:TextArea id="textarea1"/&gt; <br>        &lt;mx:Button label="Submit" click="textarea1.text='Hello World';"/&gt; <br>    &lt;/mx:Panel&gt; <br>&lt;/mx:Application&gt; <br>

The ActionScript 3 bundle will provide you with a buildin “Build (mxmlc)” command, but I prefer just compiling the files direct with Terminal.app:

gersh:~/Desktop/Adobe Flex/HelleWorldFlex gerhard$ mxmlc FlexTest1.mxml<br>Loading configuration file /Developer/SDKs/flex_sdk_3/frameworks/flex-config.xml<br>/Users/gerhard/Desktop/Adobe Flex/HelleWorldFlex/FlexTest1<br>.swf (164508 bytes)<br>gersh:~/Desktop/Adobe Flex/HelleWorldFlex gerhard$ 

If you have installed the last version of flash-player you will be able to open the .swf file in Finder.

Permalink for Using Flex SDK on mac
Nov 25

Tutorial: Convert RSS to JSON with PHP and import the JSON into Flash with AS 2

Written: Nov 25th 2007, 21:48

Recently we had a customer at the office who wanted a news feed from a related site displayed on their homepage. As a design element we wanted to extract the first image in the description part of each news item in the feed and display it in a separate container inside the flash file.

Permalink for Tutorial: Convert RSS to JSON with PHP and import the JSON into Flash with AS 2

Page 1 of 1