Thursday 18 February 2010

Setting up Apache and IIS on the same machine

Just a quick note to myself more than anything so I remember in the future.

I am currently trying to get both IIS and Apache running on my web server. The reason for this is because I want to move my SVN server from my home server to my remote server. This will mean that my SVN server can have it’s own static IP and run with apache on port 80 as a http server.

The problem was that by default IIS binds to all the IP addresses available to the server so that Apache was not able to bind to any.

I found this blog post very helpful.

To summarise:

  • Make sure httpcfg is installed – you might need to download the support tools
  • type the following command for each IP address that you want IIS to listen on:
    httpcfg set iplisten –i XXX.XXX.XXX.XXX
  • confirm the IP list you have created with:
    httpcfg query iplisten
  • restart http service:
    net stop http /y
    net start w3svc

That’s it. I now have Apache and IIS running on my server, both on port 80 but on different IPs. Now all I have to do is link Apache up to SVN and copy my dump of my local repository across.

Thursday 11 February 2010

SWCInspector v 0.2

I’ve uploaded a new version of SWCInspector. People at work, including myself, are already finding this pretty useful even with this early set of features.

The new version is here. I’ll update this html page to point at new versions as I upload them.

New features / fixes:

  • Big improvements to the renderers – they were very dodgy on scrolling before
  • Added a label to the selected asset indicating class name and swc that it came from
  • Added the ability to draw a box to display the asset bounds
  • Display bounds in the property pane so you can check 0,0 registration
  • Improved the width and height adjustment
  • Improvements to model wiring – more parsley based

If you find this useful let me know. I’ve got a lot more features that I want to implement but if you have any suggestions let me know.

The wife is away this weekend so hopefully there’ll be another version before Monday!

Sunday 7 February 2010

SwcInspector

At work all the assets that we use to create the applications are contained in swcs. These swcs are created in Flash and are used like any other library in Flex.

There can be a lot of assets and it can be hard to find the one that you are looking for. It is also handy to be able to test the asset before it actually gets into the application – see what states are defined and how it looks when it is re-sized to make sure the slice-9 is set up properly.

As we’re just getting to a point on my current project where we’re getting lots of assets delivered I put SwcInspector together this weekend. It is not finished yet but there is already quite a bit of useful functionality in there:

  • The ability to load multiple swcs into the application
  • Filtering of loaded asset list
  • Visibility of states defined for each asset
  • Resizing of assets to test slice-9
  • Adjustment of background color for white / light assets

As I said it’s not finished. The existing functionality needs some tweaking and there is some more functionality that I want to implement.

Unfortunately I can’t let you have a copy of the assets we use at work for obvious reasons. I found this swc courtesy of this blog for you to download and try out with the application if you so want to.

You can have a look at the application here. Using it with a swc with only 1 asset isn’t really a very good example but that’s all I’ve got I’m afraid! If you use swcs yourself give it a try and let me know how it goes – I have only been able to test it on a few so  wouldn’t be surprised if there are issues.

I’ll post again when I’ve made some progress. I can make the code available to anyone who’d like a look. If you want a copy please e-mail me.

Saturday 6 February 2010

AsyncTokenWrapper is Dead, Long Live AsyncTokenWrapper

As I said in the comments of my last post about AsyncTokenWrapper I didn’t like the way I was wrapping AsyncToken and handling the response.

A much neater solution to this is to create and register a custom command factory. You register a command based on the return type of your function. In my case I am returning a ProcessingAsyncToken so I go about registering my factory like this:

GlobalFactoryRegistry.instance.messageRouter.addCommandFactory( 
ProcessingAsyncToken,
new ProcessingCommandFactory()
);

I do this in a support class that implements ContextBuilderProcessor so that I can set this up when I create my context:





My command factory looks like this:

public class ProcessingCommandFactory implements CommandFactory
{
public function createCommand(
returnValue : Object,
message : Object,
selector : * = null
) : Command
{
return new ProcessingCommand( returnValue,
message,
selector
);
}
}

And just returns a new instance of my ProcessingCommand:

public class ProcessingCommand extends AbstractCommand
{

//-------------------------------------------------
//
// Constructor
//
//-------------------------------------------------

public function ProcessingCommand(
returnValue : *,
message : Object,
selector : *
)
{
super( returnValue, message, selector );

_processingToken = ProcessingAsyncToken( returnValue );

_processingToken.token.addResponder(
new Responder( complete, error )
);

start();
}

//-------------------------------------------------
//
// Private Variables
//
//-------------------------------------------------

private var _processingToken : ProcessingAsyncToken;

//-------------------------------------------------
//
// Overridden Methods: AbstractCommand
//
//-------------------------------------------------

protected override function selectResultValue(
result : *,
targetType : ClassInfo
) : *
{
return ( targetType.getClass() != ResultEvent && result is ResultEvent )
? ResultEvent( result ).result
: result;
}

protected override function selectErrorValue(
result : *,
targetType : ClassInfo
) : *
{
return ( targetType.getClass() == Fault && result is FaultEvent )
? FaultEvent( result ).fault
: result;
}

override protected function complete( result : * = null ) : void
{
var argumentsArray : Array;

if ( _processingToken.resultProcessingFunction != null )
{
try{
argumentsArray = _processingToken.resultProcessingArguments.concat();
argumentsArray.unshift( result.result );
result = _processingToken.resultProcessingFunction.apply(
this,
argumentsArray );
}
catch( e : Error )
{
error( e );
}
}

super.complete( result );
}

override protected function error( result : * = null ) : void
{
var argumentsArray : Array;

if ( _processingToken.faultProcessingFunction != null )
{
argumentsArray = _processingToken.faultProcessingArguments.concat();
argumentsArray.unshift( result.fault );
result = _processingToken.faultProcessingFunction.apply(
this,
argumentsArray );
}
super.error( result );
}

}

We just extend AbstractCommand and override the complete and error functions to apply the functions defined in ProcessingAsyncToken before passing the result on. In the constructor we add a responder to the AsyncToken in the return Value.

I call the function as follows:

[Command( type="com.pricklythistle.picasa.event.ListPicasaAlbumsEvent", messageProperties="userID,kind" )]
public function loadUserAlbums(
userID : String,
kind : String = null
) : ProcessingAsyncToken
{
url = StringUtil.substitute( BASE_URL, userID );

return loadUserEntries( kind );
}

I think this is a much neater solution that wrapping an AsyncToken inside another Async token – that had a really bad smell about it!