Archive for March, 2010

Deploying AIR Application and AIR Runtime (Redistributable) in Single Exe

March 10, 2010

In this article I show how to package an AIR application (.exe) with the AIR runtime redistributable in a setup file. Your end-users can then run a single setup.exe file to install both your app and the AIR runtime. Nice one! 

This is a follow-up from an article I wrote on packaging and AIR application as an EXE

What you’ll need: 

  • The myApp.exe file you created from your myApp.air file (detailed in article mentioned above)
  • The Adobe Air 2.0 beta (or 2.0 beta 2) runtime exe file you’re currently using (can be downloaded here).

1. You have to create a zip file containing the myApp.exe file and the Adobe Air Runtime Redistributable exe file. 

Note: I firstly renamed the Air runtime file to air2runtime.exe (just for handiness), and called the zip file installFiles.zip 

2. Install and open InstallJammer. 

3. Choose File/New/Project Wizard. Enter a project name and destination folder for your InstallJammer project, I named mine Air Install Project, click next. 

4. Enter some details for you apps’ name and version, next. 

5. Step 4 asks for your Application Directory, where your air files are. I just leave this blank, and add my files later. 

6. The next three steps are simple. Install wizard theme, os to install on (Windows for me), additional features (the default will do). 

7. Next we want to add our zip file to the project. 

  • Click on ‘Groups and Files’
  • Right click Program Files, and browse to your zip file (see pic below)

Groups and Files

Read the complete tutorial here (steps 8 – 12)………

Flex Stacked Chart: Display custom dataTip total value

March 4, 2010

Once you use a custom dataTip (dataTipFunction = “myDataTipFunction”) in a stacked chart, its not possible to directly access the total value of items in a column/bar.

This means that your custom dataTips will be without the % and total values that appear (as a default) on Flex stacked charts. This problem is now solved in a simple manner!

Custom DataTip - with % and Total

The function below gets around this problem, and gives one access to a custom dataTip’s ‘total’ value for stacked columns/bars. Complete mxml code is in the full article.

private function myDataTipFunction(hitData:HitData):String
{
	var itemsDictionary:Dictionary = new Dictionary();
	var total:Number = 0;

	//hitData.item holds name value pairs for each of the
	//dataProvider's rows(sales array in this case)
	for(var property:Object in hitData.item){
		itemsDictionary[property] = hitData.item[property];
	}

	// Have to get instance of hitData.element (a ColumnSeries) to
	// access element.series.stacker.series which holds the yField
	// values e.g. toys. Note: needed as hitData.element.
	// series.stacker is not accessible directly.
	var series:ColumnSeries = ColumnSeries(hitData.element);
	for( var key:Object in itemsDictionary)
	{
		for( var i:int = 0; i < series.stacker.series.length; i++){
			// Need to check that we only add yField values, as "period-Q1"
			// is also in hitData.item along with "toys-900" etc
			if(series.stacker.series[i].yField == key.toString()){
				total += itemsDictionary[key];
			}
		}
	}

    var item:ColumnSeriesItem = ColumnSeriesItem(hitData.chartItem);
    var quarter:Object = xAxis.formatForScreen(item.xValue);
    var value:Number = Number(item.yValue) - Number(item.minValue);
    // want 2 decimal place precision
    var percent:Number = Math.round(value / total * 1000) / 10;

    return  "<b>" + series.displayName + "</b>\n" +
			"<b>------------------</b>\n" +
			"" + quarter + "\n" +
			"<b>------------------</b>\n" +
			"<b>Value:\t\t</b>" + value + " \n" +
			"<b>Percent:\t</b>" + percent + "% \n" +
			"<b>Total:\t\t</b>" + total;
}

For the full .mxml example class code….. (more…)

Deploying C# Setup.exe with .Net 3.5 Redistributable

March 4, 2010

Its annoying for end-users when they have to download the .Net 3.5 Framework via Microsofts site when installing your applications:( So why not deploy your app with the .Net framework included!

Here are the steps to add a Setup project to your VS2008 application packaged with a .Net 3.5 installer.
1. Create a new C# .Net 3.5 project (in my case a Visual C#/Windows/Windows Forms Application).

2. Right click the project title (not the solution title), and go to Properties | Publish | Prerequisites.

  • You will see that Windows Installer and .Net 3.5 are selected as default.
  • Now, check ‘Download prerequisites from same location as my application‘.
  • This avoids the end-user have the massive .Net 3.5 Framework internet based download.
  • Make sure the ‘Create setup program to install prerequisites’ at the top of the window is checked.

3. Right click on the Solution title and go to Add | New Project | Other Project Types | Setup & Deployment. Choose Setup Wizard and then OK.

  • In the setup wizard click Next, choose the 1st option in (VS 2008), ‘Create a setup for a windows application’.
  • Next, choose the project outputs. For this example ‘Primary output from myApp’ will suffice.
  • Next, add a readme file if you want (I did not want), and click Next or Finish.

4. Right click the Setup project title (Setup3pt5 in my case, see pic below), go to Properties | Prerequisites.

  • Check ‘Download prerequisites from same location as my application’.

Setup Prerequisites

Steps 5 – 10….. (more…)