I had an old Flash marketing piece that was written in actionscript 1, and I needed to load some new files that I had written in flex with actionscript 3. I was getting errors and the newer actionscript 3 swf files would not load from the actionscript 1 flash projector file.

There was a ton of code written in actionscript 1 and I didn’t want to rewrite it all since it has been working great (yeah, I know.. lazy).

So I ended up using an fscommand to exec the actionscript 3 files by converting my flex project output swf to a projector exe file. Here is how I did it:

Using your flex builder or flash builder outputed swf file, open the swf file in the stand alone Flash Player. Once you open the file in the Flash Player, click “File”

Step One - Click File

then click “Create Projector…” and you will be able to save your .swf as an .exe

Step Two - Click Create Projector

Posted: November 3, 2010, 4:55 am by Brian Radford

Windows Live Messengers shows up as two separate items in the Windows 7 taskbar. In order to fix this, if it annoys you like it does me, follow the steps below:

  1. Open the Start Menu
  2. Look for Windows Live Messenger
  3. Do not left click, instead Right Click on the icon
  4. Select Properties
  5. Look for Compatibility Tab
  6. There is a drop down list of operating systems you can choose to which the application was compatible (or in the mode you wish it to run)
  7. Select either Windows XP SP3 or Vista
  8. Click Apply
  9. Click OK
  10. Restart the application (in this case Microsoft Live Messenger)
  11. Should only show one now.

That is it. I can’t explain why this is yet, but at least you can free up some of your taskbar again. :)

Posted: January 11, 2010, 8:53 am by Brian Radford

To import a linux guest from the Xen Opensource (hypervisor) to XenServer

1. Create a new VM in XenServer, and make sure the virtual disk is at least the size of the disk you will import.

2. Get UUID from virtual disk images
xe vdi-list params=all

3. Import the raw disk image file into the virtual disk image
xe vdi-import filename="raw_image.img" uuid="UUID"

4. Boot the VM. Note: You may need boot the VM off a valid bootable ISO image first so that the drive’s location path is set.

To convert from a VMware guest to XenServer
To import a VMware linux guest first convert the vmdk to img and use the “Other install media” Template in XenServer.

qemu-img convert -f vmdk vmdk_image.vmdk -O raw raw_image.img

Posted: October 16, 2009, 3:32 pm by Brian Radford

In the past as we have moved more applications to the browser, there are some users who still struggle with the change from a desktop application to the browser. One main change is that the browser applications don’t always prompt for saving data as the user closes the browser or navigates away from the page. Changes are made, and the changes are lost as they navigate away from the page without saving. How do you ensure that changes to the data are saved before the user navigates away or closes the browser?

The javascript window.onbeforeunload event can help with this.

window.onbeforeunload = some_function

Your code can be as simple as the above, but I would recommend a few additions, e.g. checking to see if the user has made any changes before you throw up a confirmation prompt. It is always annoying to make no changes, but still be prompted to save before navigating away. In order to track if changes have been made, here is a simple javascript tracking example. Of course, your pages may be much more complicated, but this will illustrate one approach.


var values = new Array('', '', '', '', '', '');
var needToConfirm = true;

window.onbeforeunload = confirmExit;
function confirmExit()
{
if (needToConfirm)
{
// check to see if any changes to the data entry fields have been made
for (var i = 0; i < values.length; i++)
{
var elem = document.getElementById(ids[i]);
if (elem)
if ((elem.type == 'checkbox' || elem.type == 'radio')
&& values[i] != elem.checked)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
else if (!(elem.type == 'checkbox' || elem.type == 'radio') &&
elem.value != values[i])
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}

// no changes - return nothing
}
}

Enjoy this bit of code, but be careful not to over use it. It can be annoying. :)

Posted: August 3, 2009, 8:20 am by Brian Radford

If you want to check out a quick and easy way to back up your blog, check out http://www.bloggled.com/

There are several options including a FREE one. It is easy to setup and get started. Check it out!

Posted: December 15, 2008, 12:12 pm by Brian Radford

JDBC prepared statements are ideal for backend optimization. The resulting SQL does not need to be re-optimized if you are using a parameterized SQL statement. Single parameters or even parameters by name with a single value are quite simple an easy, and you can find examples all over the internet. But if you would like to pass in an array into a parameter, it may be difficult to find examples.

This is an example of how to do this with an Oracle SQL statement.

First, you will need to create a custom data type in Oracle.

CREATE TYPE t_collection IS TABLE OF NUMBER;

Then in you jdbc client, you will need to use the OraclePreparedStatement class, and some of the other Oracle provided classes.

import oracle.jdbc.OracleConnection;
import oracle.jdbc.driver.OraclePreparedStatement;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

Define your SQL statement.

select itemid, prompt from responses where itemid in (select value(v) from table(:item) v)

Notice: The (select value(v) from table(:item) v ) is using a nested table, thus the table(). We will pass in the :item as the t_collection type that we created which will be treated as a table.

Now in your method call you would:

// change from a jboss connection to an oracle connection
con = (OracleConnection)((WrappedConnection)getConnection()).getUnderlyingConnection();

// create a statement, apply the filters as parameters, add the item parameter, and execute
statement = (OraclePreparedStatement)con.prepareStatement(RESPONSES);
statement = applyFilter(statement, filter);

String[] items = itemid.split(”,”);
ArrayDescriptor desc = ArrayDescriptor.createDescriptor(”T_COLLECTION”, con);
ARRAY sarray = new ARRAY(desc, con, items);
statement.setARRAYAtName(”item”, sarray);
rs = statement.executeQuery();

Posted: August 12, 2008, 11:19 am by Brian Radford