Air. The future of RIA. Unless you try and actually use it.
I've been wanting to write a swf encryptor for ages and last night I finally cracked ( As I'm working on something that I really don't want decompiling for various reasons ).
It was a toss up between Zinc and Air, but I opted for AIR 'cause in theory it is the future and therefore should have better support than Zinc.
So after all the hype surrounding Air I should just be able to google around, find out how to drag and drop, save a file and some other basics. I develop in Flex rather than cs3 'cause it's a million times better, but any search for Flex and Air just brings up examples using MXML. That's not great.
Eventually I found a hacky way to create an Air project in actionscript in Flex ( It's so convoluted it's untrue. You create a Flex project as opposed to an AS one as usual, tick the Air box, but on the part where you set the document class you alter the mxml extension to .as and it works ).
Getting there. Published the main class and up popped... nothing. More searching and I found out how to set it up ( A big thanks to Toby for blogging about it, without his words I'd have given up all together ).
Cool, got a window in place now. Close it, try publishing it again, and... nothing. Lot's more searching ( And swearing ) and I found out what the problem was, and the cure. If you don't exit your app correctly ( ie call an exit() after adding a listener to the close button ) then it doesn't actually exit correctly ( I found this out myself after a lot of messing about ).
When you publish an air app it runs something called adl.exe ( Adobe Debugging something. I've had enough air googling for a life time so can't face looking it up ) which runs the swf wrapped in the air api.
If you don't call exit() then when you close the app adl.exe keeps running. Ok, that's not the end of the world. What actually is though, is that you can only run one instance of adl.exe. If it's running after you've closed your app incorrectly, then you can't run any more air apps.
The beautiful thing is, it doesn't tell you. Flex doesn't tell you either. It's like they've ganged up to keep us in the dark.
Until I figured out the whole exit() thing, I was working with task manager open closing it down every time. The only solutions I found online were, yep, work with task manager open and...
Ok it kinda makes sense, and if you've got to call exit() then you've got to call it, but c'mon, this is the future of RIA and I've got task manger open to kill it ?
It all feels very beta-ish, from the hacky way to even create an Air project in Flex to that.
Once I got past these hurdles, I must admit it wasn't that bad. The lack of docs ( I only found this after I'd gone through a lot of pain ) has made it a less pleasant exercise than it should have been ( Oh joy, another mxml example for something I want to do with code ).
One weird thing which I'm putting down to me is that when I drag and drop a swf into my sexy little app it runs the app twice. I don't mean it opens another window, it just runs through all the code twice ( In alcon I was getting,
which was a bit of a give away ). A little kludgy check cleared that up.
At present we've got a simple little app which you can drag a swf onto, it then encrypts that with blowfish via the very nice Crypto library and you can then save that back out.
Next up ( And what I've been swearing at for the past hour or so ) is the decryption routines. Well, the code is being embedded and decrypted, it's just figuring out how to then make that byteArray run as a swf rather than just sitting there annoying me.
Credit crunch. Man I am ever sick of that term.
Hold my a hand a minute or two whilst we go on a brief trip back in time.
Way back wealth was gauged in precious metals, mainly gold. Coins were made out of it to make life easier. Then to make life even easier they was replaced by paper bills. A bill is simply a promissory note to be exchanged for specified goods or services. On the £10 note I've just fished out of my wallet at the top it says "Bank of England. I promise to pay the bearer on the demand the sum of ten pounds". Cash is purely symbolic, it's still easier than a big sack of gold, but at the end of the day it's still just a way to show how much gold you've got. That tenner is worth £10 worth of gold, which is known as the "Gold Standard".
Sticking with the whole gold thing, the original bankers were actually goldsmiths. They worked out that it was really unlikely that everyone who had their gold stored with them would ask for the whole lot back in one big hit, so they loaned money to people based on a percentage of the gold they had bagged up in the back office. It was a bit of a balancing act, a war could come along and everyone would want to withdraw their gold in one go ( Which would lead to a "Bank run" ) but as they were charging interest on these loans it was worth the risk.
To quote author G. Edward Griffin, "[bills] are made in such vast quantity that it must equal in amount to all the treasures of the world".
Being able to print your own money is in an easy fix. Governments soon realised that you know what, fuck it, we haven't got that much gold stored away but we can print some more notes as we're running a bit low ( The process of lending out more money than you have actual gold for is called "Fractional-reserve banking" ). The offset of this being, the more money there is, the less it's actually worth ( So my £10 isn't actually worth £10 of gold, as the Bank of England has printed more notes than they've actually got gold to cover. They no longer adhere to the gold standard ). The process of too much money in the economy causing it's actual value to decrease is inflation ( When it's all going wrong it's just a downward spiral, as can be seen with what's going on with Zimbabwe's inflation rate ).
Let's go back to the good old Bank of England. It sets the base interest rate. This is basically the interest rate it charges banks for borrowing money from it. Currently it's 5%, so all the banks who want to borrow a couple of quid pay 5% on that. Now on the vast sums that are shifted around, 5% is still a ton of money coming back.
Ok, I want to borrow a couple of quid. I can't go to the Bank of England directly for a loan, so I'll go to my local high street bank. Now this is where it gets really beautiful, having a quick look at a loan comparison site, the best I can get is 7.8%
There's a bit of profit there.
Back again to Fractional-reserve banking. It is what it says. A bank only has to keep a fraction of the money it has in reserve. Say you've sold a kidney and have £10,000 to put in a bank. The bank only has to ensure that it holds on to a percentage ( Or Fraction ) of that £10k.
In the UK that percentage is voluntary (According to the wikipedia link above, in 1998 it was 3.1% ).
You've gone to the bank and paid in your £10k. Looking at savings rates, if you want to be able to take your money out fairly soon then you're looking at getting around 6.5%. Now lets say the reserve rate is 10% ( As it is in the US ). The bank will have to sit on £1000 of your money, the rest it can loan out. At 7.8%.
Not only do banks get a cheaper lending rate from the Bank of England, they make money on your money. Sweet.
So who's actually making all this money ? Who owns the banks ? Well, they all do. It's like cash incest. Despite it not even looking like a direct link, they all own shares in each other.
Right hopefully I've set the scene for why banks are not the most likable institutions. I can finally get to the part that really grinds my gears.
If a bank goes belly up, the government will dive in and "rescue" it. It happened with Northern Rock and the US has just sanctioned a bail out scheme.
As a tax payer ( The driving force behind this huge rant was a really snotty phone call from the Tax man at 5 past 9 this morning. Just 'cause my form and cheque haven't got there yet doesn't mean I want to be spoken to like I'm a fucking rapist first thing in the morning, thanks ) I now own a share of Northern Rock. Or rather, my tax is paying to keep that bank afloat. As more and more banks get into trouble more and more of our tax will be spent shoring them up.
In the current climate mergers are going to be more common place ( Such as the Lloyds / HBOS merger ). The credit crunch is a bad scary thing, we're all paying more for things in shops, getting a loan or a mortgage is a lot trickier, but in two years time it'll all be forgotton. But these huge banking mergers which have actually been sanctioned by the government will still be in place, giving us as consumers less choice than before.
To recap. Banks can borrow cheaper than we can, and then lend to us for a profit. Banks pay interest on what we save with them but then lend it back to us at a profit. If we fail to repay that loan we can either be imprisoned or have our property taken. If a bank gets burnt by lending money to too many people who then default, our income tax will help keep it going, because the other side, the bank crashing, is even worse for the economy than nationalising it.
It's pretty much stacked in their favour on every level. You bounce a cheque you'll pay a £30+ fine, they screw up by taking too many risks ( ie To generate even more profit for their shareholders, the majority of which are their fellow banks ), we pay again to prop them up.
A very simple and naive summary I know, and possibly riddled with flaws. If you want to read real facts rather than my stabs in the dark I can recommend the book "The Shock Doctrine" by Naomi Klen ( Check out Amazon ) which equates the money markets to actual physical torture, and is an eye opening read.
Hang on, this has nothing to do with Flash or games. Arse.