deepsplink released

May 27th, 2009

I'm proud to anounce the release of deepsplink, an actionscript 3 deeplinking framework. deepsplink provides a clear, flexible and easy to use api to build a scalable actionscript 3 application very quickly.
The source code, the api documentation and a simple demo application which showcases the main features can be found at googlecode


No Comments »




splinklibrary & splinkresource updates

May 26th, 2009

I just released new versions of splinklibrary and splinkresource. The version number is now 1.0.0 as both projects are pretty stable and have been used in a number of projects. The splinklibrary classes are now covered by unit tests.

I also improved the public api's of the queue (which is now even more powerful and easy to use), the tween engine (which runs a bit faster and is now much more convenient to use) and the shape package.

Because of the changes to the public api, splinklibrary is not backward compatible as previous versions were, which is the main reason for the splinkresource update (no new features there).

You can access the new versions here:

splinklibrary
splinkresource


No Comments »




splinklibrary feature demo

October 18th, 2008

here is a quick demo class showcasing a few splinklibrary features. Please note that this example focuses on showing some splinklibrary features and it is not considered to be a best practice approach for loading and tweening an image. Also note that the demo is just a teaser, splinklibrary has a lot more useful concepts to offer. I recommend you to checkout the source and see for yourself.

 
package
{
import org.splink.library.loading.QLoader;
import org.splink.library.loading.QUrlLoader;
import org.splink.library.logging.ILogger;
import org.splink.library.logging.ILoggerFactory;
import org.splink.library.logging.LogLevel;
import org.splink.library.logging.LogRange;
import org.splink.library.logging.LoggerFactory;
import org.splink.library.logging.LoggerProvider;
import org.splink.library.logging.logoutput.DefaultOutputFormatter;
import org.splink.library.logging.logoutput.FirebugOutput;
import org.splink.library.logging.logoutput.QLogOutput;
import org.splink.library.queue.Queue;
import org.splink.library.queue.QueueEvent;
import org.splink.library.queue.QueueResultProvider;
import org.splink.library.queue.ResultQueue;
import org.splink.library.tween.TweenAction;
import org.splink.library.tween.TweenPool;
import org.splink.library.tween.sprop.FilterProp;
 
import mx.effects.easing.Sine;
 
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.filters.BlurFilter;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
/**
 * This class demos the usage of some of the splinklibrary classes.
 *
 * @author Max Kugland
 */
public class Demo extends Sprite
{
private var _logger:ILogger;
 
/**
 * Configure the logger once for the project
 */
private function configureLogger():void
{
	// we need an ILoggerFactory, which will create our ILogger instances
	var factory:ILoggerFactory = new LoggerFactory();
	// set a factory id
	factory.setId("demo");
	// set the range of LogLevels which will be logged
	factory.setRange(new LogRange(LogLevel.TRACE, LogLevel.FATAL));
	// set an IOutputFormatter to format our logmessages
	factory.setOuputFormatter(new DefaultOutputFormatter("demo-app"));
	// add ILogOuputs which will send the logs to their destination,
	// in this case we let the logs appear in QLog and in Firebug
	factory.addLogOutput(new QLogOutput());
	factory.addLogOutput(new FirebugOutput());
	// add the factory to the LoggerProvider
	LoggerProvider.addLoggerFactory(factory);
 
	// get an ILogger from the LoggerProvider using the ILoggerFactory
	// with the id "demo"
	_logger = LoggerProvider.getLogger("demo", Demo);
}
 
public function Demo()
{
	configureLogger();
 
	// log a message with the LogLevel INFO, as INFO is within the
	// specified LogRange, the message will get logged
	_logger.log(LogLevel.INFO, "starting Demo");
 
	// Create a ResultQueue and register listeners for error and
	// completion events as ResultQueue is capable of distributing
	// events because it extends Distributor
	var queue:ResultQueue = new ResultQueue;
	queue.register(QueueEvent.ON_COMPLETE, onComplete);
	queue.register(QueueEvent.ON_ERROR, onError);
 
	// add a loader to the queue which loads xml and assign it an id
	//(feedResult)
	queue.add(new QUrlLoader(
	new URLRequest("http://splink.org/?feed=rss2"),
	URLLoaderDataFormat.TEXT, "feedResult"));
 
	// add a loader to the queue which loads an image and register a
	// listener for its completion event, also pass the queue instance
	// (q) to enable it's usage within the method which is called on
	// it's completion, (QLoader also extends Distributor and therefore
	// can fire events)
	queue.add(new QLoader(
	new URLRequest(
	"http://splink.org/wp-content/themes/splink/img/header.jpg"))).
	register(QueueEvent.ON_COMPLETE, onImage, queue);
 
	// start the queue
	queue.start();
}
 
/**
 * Called when the image loader completes
 *
 * @param e the event sent by the image loader
 * @param q an optional object, in this case the queue
 */
private function onImage(e:QueueEvent, q:Queue):void
{
	// unregister from the event source (the image loader)
	e.getSource().unregister(QueueEvent.ON_COMPLETE, onImage);
 
	// cast the event source (IDistributor) to QLoader
	var loader:QLoader = (e.getSource() as QLoader);
 
	// add the loaded image data to the stage, and set it's alpha
	// value to 0
	var bmp:DisplayObject = loader.getContent();
	addChild(bmp).alpha = 0;
 
	_logger.log(LogLevel.TRACE, "image present: " + bmp);
 
	// create a bitmapfilter which is used for tweening
	var fprop:ISpecialProp = new FilterProp(new BlurFilter(0, 0, 1));
 
	// create a TweenPool and add some TweenActions targeting the
	// loaded image (bmp). tween the alpha from it's current value
	// (0) to 1 and tween the blurX  and blurY properties of the image
	// from 100 to 0
	var t:TweenPool = new TweenPool;
	t.add(new TweenAction(bmp, Sine.easeOut, 500,
	TweenAction.ALPHA, bmp.alpha, 1));
	t.add(new TweenAction(bmp, Sine.easeOut, 500,
	TweenAction.BLUR_X, 100, 0, 0, fprop));
	t.add(new TweenAction(bmp, Sine.easeOut, 500,
	TweenAction.BLUR_Y, 100, 0, 0, fprop));
	// add the TweenPool to the end of the queue
	q.add(t);
}
 
/**
 * If one of the queued operations fails, we get notified here
 */
private function onError(e:QueueEvent):void
{
	_logger.log(LogLevel.ERROR, "Demo error " + e.getErrorMessage());
}
 
/**
 * As the queue continues even if a queued operation fails onComplete
 * gets called in any case.
 */
private function onComplete(e:QueueEvent):void
{
	// as we used a ResultQueue we can retrieve a QueueResultProvider
	// which carries the results of the IResultQueueable items within
	// the ResultQueue. Note that the TweenPool is not an
	// IResultQueueable but an IQueueable, as it doesn't compute any
	// results, so the QueueResultProvider only holds the  results of
	// both loaders (the image loader and the xml loader)
	var p:QueueResultProvider =
	(e.getSource() as ResultQueue).getResultProvider();
 
	// here we retrieve the result with the id "feedResult" from the
	// QueueResultProvider and as we know its content is xml we cast
	// it to xml
	var xml:XML = XML(p.getResultById("feedResult").getResult());
 
	// we log the title of the loaded xml document which is a rss feed
	// at the TRACE LogLevel and ouput that the demo is complete at
	//INFO level
	_logger.log(LogLevel.TRACE, "xml feed title: "+xml["channel"].title);
	_logger.log(LogLevel.INFO, "Demo complete.");
 
	// Eventually we invoke finalize on the event source which results
	// in removement of all the registred listeners
	e.getSource().finalize();
}
}
}
 

1 Comment »




splinklibrary 0.2.0 and QLog 1.1 releases

September 16th, 2008

I just relased a new version of splinklibrary. There are a few bugfixes, some performance improvements and several new features:

- the logging framework is now prepared to address the new QLog features "tabbed logging" and "navigatable tree tabs"; If you use QLog you can send the current flash displaylist or the structure of any object to QLog which opens a new tab containing a navigatable tree of the displaylist or the object.

- the tween engine is now more than twice as fast, flexible and extendable
- there is a new "tree" package which makes working with tree structures quite convenient. For instance it is used internally to serialize the flash displaylist or any object into xml which can be sent via QLogOutput to QLog.

For more details see the splinklibrary svn changelog
To download the splinklibrary-0.2.0 release directly, click here or you can get it from the google code svn

QLog now supports a new kind of tab, the "tree tab" which is capable of displaying any xml structure sent by a client as a navigatable tree. Note that you need splinklibrary-0.2.0 in order to use the "tree" feature. You can grab the QLog 1.1. release here


No Comments »




QLog update

September 1st, 2008

I just added another couple of features to QLog and also made some major refactorings under the hood.
Now Qlog enables you to change the font size, it provides keyboard shortcuts for everything, there is a new useful scroll-lock toggle button which helps if you want to read the logs while new log messages arrive. QLog also exports your logfiles now as valid xhtml 1.0 strict files and saves all settings like window position, size and various other settings on exit, to spare you from the pain to adjust the settings each time you start QLog. Furthermore it enhances working with log tabs by highlighting tabs which are currently not focused but contain unread messages.

Get the latest QLog version here


No Comments »




splinkresource 0.2.0 released

August 29th, 2008

I just released a new version of the splinkresource project. It carrys only a few changes, but as I had to change the public api code is affected which relies on the 0.1.0 splinkresource api. Therefore I decided to make it a 0.2.0 release.

I you are not familiar whith the splinkresource framework yet I suggest you to read this article.

The new version now separates the code libraries declaration from the resourcebundles as code libs usally don't relate to language changes. It means that you can instruct splinkresource to load a resourcebundle for a given locale and decide whether to load your code libraries too. This is useful, because initially you probably want to load the code libraries into your application, but later when you just switch to another language you dont need to load the code libraries again.


No Comments »




New QLog release

August 27th, 2008

hi folks,

I recently became aware of a couple of features I really needed in QLog so I finally sat down to implement them.

Because I am currently working on an application which consits of several modules, each with it's own logger, the view of all the modules log messages in one window became quite cumbersome to read. So I wanted to see the logs of the modules each in a seperate tab to be able to better distinguish between them. Today I finally implemented this feature and QLog is now capable of creating different tabs for each logger connection. Thanks to the new tabs the information is far better structured and reading logs from different modules is now quite convenient.

Sometimes it's handy to save the logs to a file. That could be for instance to be able to compare the logs later, or simply to send them to someone else.  This can now easily be done through QLog's new save file feature, which renders a html file for the currently opened log tab.

I also discovered and fixed a bug which occurred only with the flash player versions 9,0,124,0 or above, because these and future flash player versions need the server to send a socket policy file to the client in order to establish a connection. read more

Well, that's it. You can download the latest QLog release here.

Hopefully fsteeg will add the new features to his eclipse plugin version of QLog soon.


No Comments »




splinkresource 0.1.0 framework released

July 26th, 2008

splinkresource aims to ease the workflow with resources in actionscript3 multilanguage applications. It supervises the processing of resources by loading and registring display assets, fonts and class libraries. During resource loadtime it offers detailed information on the load progress of the currently loading resource but also on the overall resource load progress. Moreover it provides conventient access to the processed resources within your application.

In particular splinkresource simplifies the development of actionscript 3 multilanguage applications by offering the concept of localized resourcebundles. Each resourcebundle contains information on and references to resources availible within the context of a locale. So the framework loads and provides only the resources needed for the specified locale. If your need to switch to another locale during runtime, you just pass the new locale to the framework and let it process the corresponding resourcebundle. Upon completion you have access to resources within the context of the new locale.

Of course splinkresource integrates well into the splinklibrary queue system. For instance you can add splinkresource easily into your application bootstrapping.

Because I believe in examples
The rough workflow with splinkresource is to:

- create an xml file based on the resourcebundles.dtd shipped with splinkresource. The file might look like:

 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resourcebundles SYSTEM "resourcebundles.dtd">
<!-- Sample xml Note that id values MUST BE UNIQUE -->
<!-- defaultLocale is the locale which is loaded by default -->
<resourcebundles defaultLocale="de_DE">
 
<!-- For multilanguage applications define a resourcebundle
for each locale -->  
 
<!-- locale defines the locale for the resourcebundle
package -->
<resourcebundle locale="de_DE">
	<!-- path is the path to the asset files, relative from
	your applications root directory -->
	<assets path="assets/">
		<!--
		 id is the assets id
		 src is the assets source
		 register defines a subclass of
		 org.quui.resource.AssetRegister in which the assets are
		 specified
		 -->
		<asset id="sample assets" src="assets.swf"
		register="sample.SampleAssetRegister" filesize="16375" />
	</assets>
	<!-- path is the path to the font files, relative from
	your applications root directory -->
	<fonts path="fonts/">
		<!--
		id is the name of the font
		type is the identifier which you use within your
		application to access a FontData object
		src (optional) the fonts source
		isSystemFont (optional) default value is false
		xOffset,yOffset (optional) enables to define a x/y offset
		for a specific font type
		sizeOffset (optional) enables to define a size offset
		for a specific font type
		-->
		<font id="Futura LT Condensed Bold" type="headline"
		src="futura_western.swf" filesize="26908" />
		<font id="Arial" type="text" src="arial_western.swf"
		filesize="104710" />
		<font id="Verdana" type="system" isSystemFont="true"
		xOffset="5" yOffset="5" sizeOffset="-3" filesize="0" />
	</fonts>
 
		<!--
		path is the path to the library swf files, relative
		from your applications root directory a quick way to
		get a library swf is to generate an swc (which in fact
		is a zip archive) and extract the swf within. To gain
		autocompletion for dynamically loaded class swfs:
		as fdt user you can add the swc as "runtime shared
		code" in your "fdt sourcefolder" tab or as flex user
		add the swc to the "flex build path" and switch the
		"default link type" for your swc from "merged into
		code" to "runtime shared library". These steps cause
		the compiler not to compile the code into your swf
		(because the code will be loaded during application
		runtime), but enable the editor to use the swc for
		autocompletion
		-->
<libraries path="library/">
		<!--
		id is the librarys id
		src is the librarys source
		-->
<library id="de.polygonal.as3ds" src="as3ds.swf"
		filesize="43654" />
	</libraries>
 
</resourcebundle>
 
<resourcebundle locale="en_US">
	<assets path="assets/">
		<asset id="assetA" src="assetA.swf"
		register="DefaultAssetRegister" filesize="0" />
		<asset id="assetB" src="assetB.swf"
		register="DefaultAssetRegister" filesize="0" />
	</assets>
	<fonts path="fonts/">
		<font id="Futura LT Condensed Bold" type="headline"
		src="futura_western.swf" xOffset="3" yOffset="3"
		sizeOffset="2"
		filesize="26908" />
		<font id="Arial" type="text" src="arial_western.swf"
		sizeOffset="-2"
		filesize="104710" />
		<font id="Verdana" type="system" isSystemFont="true"
		filesize="0" />
	</fonts>
</resourcebundle>
 
</resourcebundles>
 

- use the org.splink.ant.filesizeinjectortask.jar ant task and integrate it into the build process. Have a look at the sample build file:

 
<?xml version="1.0" encoding="UTF-8"?>
 
<!-- @author Max Kugland -->
<project name="org.splink.resource.sample" default="build_sample"
basedir="../">
<property file="build/build_${user.name}.properties" />
 
	 <!-- project folders -->
<property name="dependencies" value="${basedir}/dependencies" />
<property name="build" value="${basedir}/build" />
<property name="sample" value="${basedir}/sample" />
<property name="xml" value="${basedir}/xml" />
<property name="source" value="${basedir}/src" />
 
    <taskdef name="sizeinjector"
	classname="org.splink.ant.SizeInjectorTask"
	classpath="${basedir}/build/org.splink.ant.filesizeinjectortask.jar" />
 
	<target name="inject" description="Inject file sizes into the
	resources xml file">
        <sizeinjector file="${resourcefile}"
		resourcebasedir="sample" />
    </target>
 
	<target name="build_sample_assets">
		<exec executable="${flex.mxmlc}">
		<arg line="-default-size 1 1" />
		<arg line="-default-frame-rate=30" />
		<arg line="-library-path '${flex3libsdir}'" />
		<arg line="-default-background-color=0xffffff" />
		<arg line="-source-path ${source}" />
		<arg line="-output ${sample}/assets/assets.swf" />
		<arg line="${source}/sample/SampleAssetRegister.as" />
	    </exec>
	</target>
 
	<target name="build_sample"
	depends="build_sample_assets, inject">
		<exec executable="${flex.mxmlc}">
		<arg value="-debug=true" />
		<arg line="-library-path '${flex3libsdir}'" />
		<arg line="-library-path '${org_splink_library}'" />
		<arg line="-external-library-path+='${basedir}/${as3ds}'" />
		<arg line="-default-size 640 480" />
		<arg line="-default-frame-rate=30" />
		<arg line="-default-background-color=0xffffff" />
		<arg line="-sp ${source}" />
		<arg line="-o ${sample}/sample.swf" />
		<arg line="${source}/sample/SampleApplication.as" />
	    </exec>
	</target>
</project>
 

- invoke splinkresource from within your application code, register a few listeners and let it do the work. splinkresource processes your resourcebundles.xml file, loads the neccessary resources for the given locale into the given ApplicationDomain and registres the the loaded resources. Meanwhile it provides you with infomation about the loading progress and upon processing completion you can access the resources within the given ApplicationDomain through the singleton class ResourceProvider.

package sample
{
imports...
public class SampleApplication extends Sprite
{
public function SampleApplication()
{
	// pass the path to the resourcebundles.xml, also pass the locale
	// for which to load resources, also register for various events
	var processor:ResourcebundleProcessor =
	new ResourcebundleProcessor("../xml/resourcebundles.xml", "de_DE");
	processor.register(QueueEvent.ON_ERROR, onProcessError);
	processor.register(QueueEvent.ON_COMPLETE, onProcessComplete);
	processor.register(ResourcebundleProcessorProgressEvent.PROGRESS,
	onProgress);
	processor.start();
}
 
/**
 * Invoked when the resource loading progresses, as you can see you
 * get provided with a lot
 * of information on the load progress
 */
private function onProgress(
e:ResourcebundleProcessorProgressEvent):void
{
	var progress:ResourceProgress = e.getResourceProgress();
 
	var br:String = "\r\n";
 
	trace(progress.getId()+" "+progress.getCurrentItem() +
	" / " + progress.getTotalItems() + br);
 
	trace(
	Math.round(progress.getCurrentItemBytes() / 1024) + "kb / " +
	Math.round(progress.getCurrentItemTotalBytes() / 1024) + "kb " +
	progress.getCurrentItemPercent() + "%"+br);
 
	trace(
	Math.round(progress.getTotalLoadedBytes() / 1024) + "kb / " +
	Math.round(progress.getTotalBytes() / 1024) + " kb " +
	progress.getTotalPercent() + "%"+br);
} 
 
/**
 * Invoked when an error occurs
 */
private function onProcessError(e:QueueEvent):void
{
	trace(e.getErrorMessage());
}
 
/**
 * Invoked when the ResourcebundleProcessor completed its
 * processing
 */
private function onProcessComplete(e:QueueEvent):void
{
	e.getSource().finalize();
 
	testAssets();
	testFonts();
}
 
/**
 * Renders one of the assets defined in resourcebundles.xml to
 * the screen
 * Note that you can access assets trough the
 * ResourceProvider.getInstance().getAssetClassById method
 */
private function testAssets():void
{
	var SplinkAssetClazz:Class =
	ResourceProvider.getInstance().getAssetClassById(
	SampleAssetRegister.SPLINK_ASSET);
	addChild(new SplinkAssetClazz());
}
 
/**
 * Renders some fonts defined in resourcebundles.xml to
 * the screen
 */
private function testFonts():void
{
	var fontData:FontData =
	ResourceProvider.getInstance().getFontDataByType("headline");
 
	var textFormat:TextFormat = new TextFormat();
	textFormat.size = 20;
	textFormat.font = fontData.getId();
	var textField:TextField = new TextField();
	textField.defaultTextFormat = textFormat;
	textField.autoSize = TextFieldAutoSize.LEFT;
	textField.htmlText = fontData.getId();
	if(fontData.getIsSystemFont() != true)
		textField.embedFonts = true;
	textField.x = 0;
	textField.y = height + 20;
 
	addChild(textField);
}
}
}
 

Note that there is a quickstart sample included in the release so you can easily start trying splinkresource.
You can download splinkresource here


No Comments »




AsBeanGen - Generate value objects for DTD driven XML files

June 28th, 2008

AsBeanGen is a class generator application written in java which generates as3 data bean classes from DTD files. Overall it shortens development time a lot, because it rids you of spending a considerable amount of time on writing data bean classes.
Instead AsBeanGen can generate hunderts of classes in less than a second for you and as an added bonus it doesn't just generate the bean classes, but also the classes which transform the content of an XML file (implementing the DTD) to data bean objects. So finally you just have to write two lines of code yourself to get a strongly typed object representation of an XML file.

If you never heard of DTD (Document Type Definition), I suggest you to read this.
As DTD doesn't support type information natively, you also have to annotate the DTD files through simple comments to add the neccessary type information, otherwise AsBeanGen uses 'Object' as the standard type.

To give you a more specific idea how it is used, let's jump straight into an example:

This is the annotatd DTD file

 
<?xml version="1.0" encoding="UTF-8"?>
 
<!ELEMENT test (size,fonts+) >
 
	<!--
		Sets the types for the properties of the SizeData class 
 
		TYPE size.width=int
		TYPE size.height=int
	-->
	<!ELEMENT size EMPTY >
	<!ATTLIST size
		width CDATA #REQUIRED
		height CDATA #REQUIRED
	>
 
	<!--
		Sets the types for the properties of the FontsData class
 
		TYPE fonts.path=String
 
		Generates 'getFontDataById(id:String):FontData' method into
                FontsData class
		GENERATE font.id
 
		Generates 'getFontDataByName(name:String):FontData' method
                into FontsData class
		GENERATE font.name
	-->
	<!ELEMENT fonts (font+) >
		<!ATTLIST fonts
			path CDATA #REQUIRED >
 
			<!--
				Sets the types for the properties of the
                                FontData class
 
				TYPE font.id=String
				TYPE font.type=String
				TYPE font.name=String
				TYPE font.src=String
				TYPE font.systemfont=Boolean
			-->
			<!ELEMENT font EMPTY >
				<!ATTLIST font
					id CDATA #REQUIRED
					type CDATA #REQUIRED
					name CDATA #REQUIRED
					src CDATA #REQUIRED
					systemfont (true|false) #IMPLIED
				>
 

This is an xml file based on the DTD

 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE test SYSTEM "test.dtd">
 
<test>
	<size height="100" width="100"/>
	<fonts path="fonts/">
		<font id="foo" name="Arial" src="arial.swf" type="text"/>
		<font id="foo2" name="Arial2" src="arial2.swf" type="text2"/>
	</fonts>
</test>
 

This is the generated FontsData bean class

package data.test
{
 
/**
 * Class generated by AsBeanGen
 * http://www.splink.org
 */
 
	import data.test.fonts.FontData;
 
	public class FontsData
	{
		private var _path : String;
		private var _fontData : Array;
 
		public function FontsData()
		{
		}
 
		public function getPath() : String
		{
			return _path;
		}
 
		public function setPath(value:String) : void
		{
			_path = value;
		}
 
		public function getFontDataById(id:String) : FontData
		{
			var data:FontData;
			var r:FontData = null;
			for (var i:int=0; i&lt;_fontData.length; i++)
			{
				data = _fontData[i];
				if(data.getId() == id)
				{
					r = data;
					break;
				}
			}
			return r;
		}
 
		public function getFontDataByName(name:String) : FontData
		{
			var data:FontData;
			var r:FontData = null;
			for (var i:int=0; i&lt;_fontData.length; i++)
			{
				data = _fontData[i];
				if(data.getName() == name)
				{
					r = data;
					break;
				}
			}
			return r;
		}
 
		/**
		* @return an array of FontData objects
		*/
		public function getFontDataArray() : Array
		{
			return _fontData;
		}
 
		/**
		* @param an array of FontData objects
		*/
		public function setFontDataArray(value:Array) : void
		{
			_fontData = value;
		}
 
	}
}
 

This is the generated FontsDataReader class for the FontsData bean class

package data.test
 
{
 
/**
 * Class generated by AsBeanGen
 * http://www.splink.org
 */
 
	import data.test.FontsData;
	import data.test.fonts.FontDataReader;
 
	public class FontsDataReader
	{
		private var _xml : XML;
 
		public function FontsDataReader(xml:XML)
		{
			_xml = xml;
		}
 
		public function read() : FontsData
		{
			var fontsData:FontsData = new FontsData();
 
			fontsData.setPath(_xml.@path);
 
			fontsData.setFontDataArray(readFontData());
 
			return fontsData;
		}
 
		private function readFontData() : Array
		{
			var rAr:Array = [];
			for each(var xml:XML in _xml['font'])
			{
				var reader:FontDataReader = new FontDataReader(xml);
 				rAr.push(reader.read());
			}
			return rAr;
		}
	}
}
 

This is what the generated structure looks like:

This is how to use the generated classes in your application:

 
// TestDataReader is the root reader and expects the loaded xml file
// as a parameter.
var reader:TestDataReader = new TestDataReader(xml);
// TestDataReader's read method returns the root object of the
// generated tree, filled with values from the given xml.
var data:TestData = reader.read();
 

AsBeanGen can be used as a commandline application (usage shown below), or, if you are eclipse user you can add it as an 'External Tool' which proves to be very convenient (at least to me).

java -jar AsBeanGen.jar
test.DTD C:\your\project\src de.your.package.name.test

Note that the "test" in the package name is the name of the DTD file.

How to add AsBeanGen as an 'External Tool' in Eclipse

1) Open your annotated DTD file
2) Open the 'External Tools'



3) Create a 'New Launch Configuration'
4) Fill the form (see screenshot)

4) After configuring AsBeanGen, you will want it to appear in the External Tools favorites. Switch to the 'Common' tab and check 'External Tools' within the 'Display in favorites menu' box.
5) Press 'Apply' button

Now you should be able to launch AsBeanGen from the 'External Tools Favorites Bar'. Just make sure that the DTD from which you wish to generate the actionscript classes is opened and focused.

Download AsBeanGen


12 Comments »




QLog + splinklibrary Logging

May 30th, 2008

QLog is a java application which simply displays log messages. It enables to apply a filter to these messages so you can seek for a specific log or just display log messages which apply to the filter.

Because QLog is in fact a socket server it is also possible to display logs sent from an application which runs on a remote server. (This can be very handy). The greatest feature in my opionion is that messages sent to QLog can be equipped with a color for each kind of message (that is trace,info,debug,warn,error,fatal,...), so the messages look well arranged.

QLog view

In the whole QLog is a lot like powerflashers superb SocketOutputServer SOS but in contrast to SOS it is platform independent, it also runs on Mac Os X or Linux. (I developed it because i wanted to migrate to Ubuntu and I simply couldnt live without something like SOS)

QLog also integrates very well with the logging framework from splinklibrary. The splinklibrary logging framework comes with various ILogOutput implementations, so you can configure to which output destinations your logs are sent.
splinklibrary supports TraceOutput, FirebugOutput, SosOutput and QLogOutput out of the box. So you dont need to worry about any low level socket implementation details if you use QLog with splinklibrary.
One very useful feature of the sprinklibrary logging system is that if you run your application within the flash debug player, it adds the class- and methodname where the log originated from and if compiled with the -debug=true flag also the line number.

 
 
/**
 The Logger is configured once in a project. Each class which wants to
 log simply needs to add something like:
 private static const _logger:ILogger =
 LoggerProvider.getLogger("default", TheClassName);
 
*/
private function configureLogger():void
{
	var factory:ILoggerFactory = new LoggerFactory();
 
        /**
           It's possible to set various logger factories, so each one
           needs its own id
        */
	factory.setId("default");
 
        /**
         Logs within the specified range are sent to the log outputs
        */
	factory.setRange(new LogRange(LogLevel.TRACE, LogLevel.FATAL));
        /**
           DefaultOutputFormatter is used to format the log messages
           You can easily write and use your own IOutputFormatter
        */
	factory.setOuputFormatter(new DefaultOutputFormatter());
 
        /**
          Use different output strategies, here QLog and trace
          splinklibrary offers QLog, SOS, trace and Firebug LogOutput
          implementations. If you need something else, just implement
          the ILogOutput interface
        */
	factory.addLogOutput(new QLogOutput());
	factory.addLogOutput(new TraceOutput());
 
	LoggerProvider.addLoggerFactory(factory);
 
        /**
          Get a Logger and log something
        */
	_logger = LoggerProvider.getLogger("default", SampleApplicationClass);
        _logger.log(LogLevel.INFO, "Info");
        _logger.log(LogLevel.DEBUG, "Debug");
        _logger.log(LogLevel.ERROR, "Error");
}
 

Of course it should be quite simple to use Qlog with other Logging frameworks, or just to write a simple class to use it. splinklibararys QLogOutput should give a good impression how to do it.

Currently there is a stable QLog standalone version
Thanks to Fabian there is also a Eclipse Plugin version (very alpha) Update site: http://quui.com/update-site/
Here is a simple log4j appender class which enables to use QLog with the apache log4j framework for java.


No Comments »




Powered by WordPress