Creating SWF movies in Delphi

I reviewed Delphi+Flash for The Delphi Magazine: it’s a great product and is especially useful if you need to add animation to your application.

Merry Xmas

Here are a couple of sample animations:

Example SWF 1
Example SWF 2

And some sample code:


var Movie: TFlashMovie;
label1, label2, label3, label4: TSWFOffsetMarker;
EA: TSWFExportAssets;
begin
Movie := TFlashMovie.Create(0, 0, 400 * twips, 200 * twips, 20);
Movie.Version := 6;
Movie.SystemCoord := scPix;

Movie.AddRectangle(0, 0, 400, 300).SetLinearGradient(SWFRGBA($663300), SWFRGBA($CCFF99), 270);
Movie.PlaceObject(Movie.Shapes[0], 1);
Movie.BackgroundColor.RGB := SWFRGB(0,0,0);

{ Text }
Movie.AddFont(Font, false);
With Movie.Fonts[0] do
begin
Size := 2 * twips;
Name := 'Times New Roman';
Bold := true;
end;
Movie.AddText('The Delphi Magazine', cswfWhite, Movie.Fonts[0], Point(0, 100), taRight);
Movie.AddSprite;
With Movie.Sprites[0] do
begin
PlaceObject(Movie.Texts[0], 10);
with PlaceObject(Movie.Texts[0], 9) do
begin
SetTranslate(2, 2);
InitColorTransform(true, -$FF, -$FF, -$FF, -150, false, 0, 0, 0, 0, true);
end;
end;
Movie.PlaceObject(Movie.Sprites[0], 10000).SetTranslate(395, 0);

{ one snow }
Movie.AddStar(0, 0, 3, -3, 4).SetSolidColor(SWFRGBA($EE, $EE, $FF, $DD));

Movie.AddSprite;
With Movie.Sprites[1] do
begin
PlaceObject(Movie.Shapes[1], 1);
With FrameActions do
begin
ConstantPool(['this', '_x', '_y', 'ZielX', 'ZielY']);
Push([400, 0], [vtInteger, vtConstant8]);
GetVariable;
Push([1], [vtConstant8]);
GetMember;
Less2;
_Not;
label1 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([1, 10], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label1);
PushConstant(0);
GetVariable;
Push([1], [vtConstant8]);
GetMember;
Push(0);
Less2;
_Not;
label2 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([1, 250], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label2);
PushConstant(0);
GetVariable;
PushConstant(2);
GetMember;
Push(0);
Less2;
_Not;
label3 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([2, 250], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label3);
Push([300, 0], [vtInteger, vtConstant8]);
GetVariable;
PushConstant(2);
GetMember;
Less2;
_Not;
label4 := _If.BranchOffsetMarker;
PushConstant(0);
GetVariable;
Push([2, 10], [vtConstant8, vtInteger]);
SetMember;
SetMarker(label4);
Push([3, 4], [vtConstant8, vtInteger]);
RandomNumber;
SetVariable;
Push([4, 4], [vtConstant8, vtInteger]);
RandomNumber;
SetVariable;
PushConstant(0);
GetVariable;
PushConstant([1, 3]);
GetVariable;
PushConstant(0);
GetVariable;
PushConstant(1);
GetMember;
Add2;
SetMember;
PushConstant(0);
GetVariable;
PushConstant([2, 4]);
GetVariable;
PushConstant(0);
GetVariable;
PushConstant(2);
GetMember;
Add2;
SetMember;
end;
ShowFrame;
RemoveObject(1);
FrameActions.GotoFrame(0);
FrameActions.Play;
ShowFrame;
end;

EA := TSWFExportAssets.Create;
EA.Assets.Objects[EA.Assets.Add('bot')] := Pointer(LongInt(Movie.Sprites[1].CharacterId));
Movie.ObjectList.Add(EA);

With Movie.FrameActions do
begin
ConstantPool(['max', 'i', 'zufall', 'bot', 'attachMovie', '_root', '_x', '_y', '_xscale', '_yscale', '_alpha']);
Push([0, 100], [vtConstant8, vtInteger]);
SetVariable;
Push([1, 0], [vtConstant8, vtInteger]);
SetVariable;
label2 := SetMarker;
PushConstant(1);
GetVariable;
PushConstant(0);
GetVariable;
Less2;
_Not;
label1 := _If.BranchOffsetMarker;
Push([2, 150], [vtConstant8, vtInteger]);
RandomNumber;
SetVariable;
Push([1], [vtConstant8]);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
Push([3, 3, 4], [vtConstant8, vtInteger, vtConstant8]);
CallFunction;
Pop;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
Push([6, 800], [vtConstant8, vtInteger]);
RandomNumber;
SetMember;
PushConstant(5);
GetVariable;
Push([3, 1], [vtConstant8, vtConstant8]);
GetVariable;
Add2;
GetMember;
Push([7, 360], [vtConstant8, vtInteger]);
RandomNumber;
SetMember;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
PushConstant([8, 2]);
GetVariable;
SetMember;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
PushConstant([9, 2]);
GetVariable;
SetMember;
PushConstant(5);
GetVariable;
PushConstant([3, 1]);
GetVariable;
Add2;
GetMember;
PushConstant([10, 2]);
GetVariable;
SetMember;
PushConstant([1, 1]);
GetVariable;
Increment;
SetVariable;
Jump.BranchOffsetMarker := label2;
label2.JumpToBack := true;
SetMarker(label1);
end;

Movie.ShowFrame;
Movie.MakeStream;
Movie.SaveToFile('demo.swf');
Movie.Free;

ShellExecute(handle, 'open', 'demo.swf', nil, nil, SW_Normal);

Graphics Cards – SLI configuration

I’m thinking of changing my desktop for a slightly more powerful unit…the current one is over four years old and is starting to show signs of its age.

I would like to move to a dual (or multi) monitor system and have read that some of the NVidia SLI configurations may or may not support multiple monitors.

I’m probably looking at a system with two NVidia 6800 cards or at a push two 7800 cards – at these prices, I can’t imagine why they wouldn’t support at least two monitors.

Are any of my readers using such a configuration? If so, would you be so kind as to post back with your recommendations please? Thanks in advance!

Automotive USB…

I would like a USB hub in my car.

I would like it to be connected to a “control centre” with a nice touchy feely responsive point’n’click screen.

I would like to be able to plug my WMA/MP3 player into a USB port and have the music play through the car’s own sound system.

I would like to be able to plug my SatNav device into another USB port and have the control centre kick into action.

I would like to be able to connect my mobile telephone to the USB hub and be able to download celebrity voices for the aforementioned SatNav.

Where can I get such good stuff?

If it doesn’t already exist, somebody with the knowledge, please, get on the case; my fee is very reasonable.

On blogging #1 – Outbreak of blogs forces rivals to take notice

In this, the first in a series of postings in the category “On blogging”, I’ll take a look at a number of issues surrounding blogging. Notably, this posting will touch on blogging as a marketing device and employee/corporate blogging. Subsequent posts will discuss these topics, and others, in more detail.

Are blogs the end of media, marketing and advertising as we know it, or vanity publishing that will eventually suffocate under sheer weight of numbers?

Earlier this year, Barry Dorrans introduced me to the work of cartoonist Hugh MacLeod. I was therefore pleased to see a piece in The Guardian of 28th November 2005 carry a sample of his work. Jennifer Whitehead’s piece Outbreak of blogs forces rivals to take notice caught my eye for a couple of reasons. Firstly, because as regular readers of this blog will know, I’m a great believer in the power of the blog: amazing things can be achieved using a simple blog posting, then letting the readership propogate the message – DeveloperDeveloperDeveloper was “marketed” in such a way. Secondly, because Barry had mentioned Hugh’s name to me, it was in the article along with a photograph of Hugh presenting on of his business cards.

Whitehead’s article re-iterates blog statistics which are generally available via Technorati. With the number of blogs being created increasing at an amazing rate of knots surely there comes a time when we’ll reach critical mass? Well, I don’t think so, not yet at least. Yes, such is the profusion of blogs today, and that number may well double in six months time, but when it comes down to it, it’s all about filling a niche or as Hugh puts it, a gaping void. Therefore, it’s all about service profusion, information and quality. Between you and me, most of the blogs that are popping up every 1/3 of a second are likely to be what Whitehead refers to as vanity publishing. So, apart from adding to the burden of the already index-heavy search engine fraternity, which means we’ll have to spend a little more time weeding out the dross in search results, we’ve got little to be worried about. Of course, in time, the search engines will improve beyond our wildest dreams and this “de-drossification” of search results won’t be necessary.

But, every so often, along comes something that fills the gaping void. If you put enough monkeys in a room with a typewriter [surely Microsoft Word? – Ed.] and give them an infinite amount time, they will, so I’m told, eventually write something akin to the works of Shakespeare. Perhaps that’s a somewhat grandiose claim, but nevertheless, if enough blogs are created, eventually some of them are going to fill the void and become killer blogs. A killer blog has all the potential to realise serious damage to existing marketing channels and has the ability to engage customers almost at a one-to-one level. Is your marketing department capable of that? I didn’t think so. The killer blog puts the employee or person who actually performs the work directly in touch with the customer or customers, and in a way ever so different from traditional e-mail. For example, when was the last time you wrote (either on paper or via e-mail) a letter of complaint? It’s likely that your letter was kept strictly “in house” when it arrived at its destination. The response may well have been tokenary in nature: “we’ve never had a problem like this before, here’s a gift voucher…” However, the advent of the Internet changed all that. One only need to search for “xyz” sucks to learn more about how other people view “xyz”, a point not missed by Clarke Ching.

Naturally, this can work to the advantage of the customer. Whitehead notes that Antony Mayfield (director at Harvard Public Relations), whose own take on Whitehead’s piece can be found here, noted that the recent Apple iPod Nano “screen scratching” problems were first reported via blogs. With such widespread appeal of gadgets like the iPod, the publicity offered by such blogs carries some awesome power. In the case of the iPod Nano, a gadget whose rise in popularity was somewhat spectacular, the problems reported via blogs forced its manufacturer, Apple, to quickly admit that there were problems with some screens and a product recall was put in place.

Whitehead’s article also makes mention of Cillet Bang’s made up celebrity/personality Barry Scott. It seems the advertising folks hired by/at Cillet Bang decided to take advantage of Barry Scott’s blog for their own marketing gain. Except they stepped over the line. Using the name of Barry Scott, the left a message for one Tom Coates whilst he was looking for his father, who he had not seen in almost 30 years. Described as clumsy and a new low for marketers, Cillet Bang have demonstrated the care that needs to be taken when moving into on-line marketing, particularly where blogging is concerned. It’s no wonder that Barry Scott’s blog has seen very few postings during the latter part of 2005. The big blog company’s Adriana Cronin-Lukas sums it up rather well in her Cillit Bang clanger blog post. Stephen Newton also presents the case somewhat succinctly.

On the other side of the fence, employers and business in general must be careful about what what its own bloggers are saying, both during working hours and in their personal time. Take the unfortunate case of Joe Gordon who lost his job at a famous booksellers after they deemed his private posts too sensitive. I see that Joe is promoting the Committee to Protect Bloggers, a group who are devoted to the protection of bloggers around the world. It’s important for employers and business to protect their asset and in the occasional extreme case, yes, you may find the occasional blog posting that goes against the grain or is close to the bone. The action you then take will be what sets you apart from your competition. Take a heavy handed approach, whereby you are essentially punishing the many instead of the few, and you may find it affects your business in ways that you may not understand. However, take a softly softly approach, lay down some basic blogging guidelines (not rules), encourage your teams (employees) to blog and interact with customers and it is very likely that you will open up entirely new marketing streams that you never knew existed. The commercial value of a blog (even a corporate blog) is on the increase. There are even genuine cases where people are being recruited to fill the position of blogger, i.e. get paid to blog – Microsoft’s Robert Scoble is a case in point.

Blogging is here to stay. It is a powerful marketing device. How you use it is up to you, but use it with care, use it properly and you will discover its power. Your rivals are likely to be examining the blogging space already, if you’re not taking heed of blogging now, catch up may prove to be difficult.

Related posts
Blogging as a marketing device
Bloggers can be sued…
TechEd 2005 – IT Blogging
TechEd 2005 – MS IT Microsoft s Blogging Engine – Construction and Delivery
TechEd 2005 – E-mail or blog?
Blogging: does this signify the end of NNTP?

RSS Bandit 1.3.0.38 is out

Via this, I see that RSS Bandit 1.3.038 is now available from here.

I’ve moved from RSS Reader to OMEA to RSS Bandit:

  • OMEA is good but seems to “take over” integrating itself with Outlook. It also “indexed” too often, causing the status bar to be used for nothing but telling me it was indexing…and it wasn’t all that fast.
  • RSS Reader was fine, but memory usage went up and up and up…
  • RSS Bandit is fine, but CPU usage seems to go close to 100% when it goes off to update feeds. None-the-less, it’s working for me right now, so I’ll recommend it and the update.

Are there any other RSS applications that I should be looking at?

Going Native with John Seddon and Systems Thinking

I had the pleasure of attending a John Seddon session last night. The event was organised by the Lothian Quality Forum and held at Standard Life. It was intended to be a Q’n’A session based on John’s earlier “Show” held at the EICC in October 2005. However, since only three attendees out of about 40 had actually attended the Show, John gave us a brief summary of the Show and some excellent eye opening advice.

John’s work in the Systems Thinking domain has some overlap with the work of Mary Poppendieck who promotes Lean Software Development. Having attended Mary’s course and read some of John’s work, and now attended a session, there are definite synergies between the two. (There you go, the word “synergy” can be used for something good after all!)

John had one slide. It came from page 11 of his book, Figure P2: Changing Management Thinking. On the left hand side we saw Command and control Thinking, on the right hand side we could see Systems Thinking. John made reference to each side throughout his pitch.

If you’ve read John’s book, you’ll know about the two types of demand: value demand (which has some profit related to it) and failure demand (which ultimately is non-profit). Failure-demand manifests itself in command and control architectures in the form of meetings and reports, neither of which are able to get hold of the causes of a particular problem (despite current command and control practitioners repeatedly trying the same thing over and over again expecting a better result each time…I believe that’s one of te definitions of insanity).

“Managing people is waste of your time…management of the system leads to a paradigm change in employee behaviour”

John made good use of experts from the field, some of whom were his employees, other not. One of the experts, currently from Norwich Union, cited the story of new employee induction training. After eight weeks of training, inducted employees could only really “do” 20% of the job (in a call centre scenario). After some careful thinking, two weeks training on the 10% most common problems saw the inducted employees performance improve considerably. Of course, for the 90% of “out of the ordinary” issues, escalation to a more senior employee prove to be the solution.

Standardised procedures seem to be the panacea to all our woes; they are seem as devices that can control the work. Standardised procedures actually see costs being driven up. In fact any attempt to control an [employee’s] activity has the same negative effect (costs go up). Indeed, standardising procedures in a service industry serves only to drive costs up – they cannot handle the variety and failure-demand that is inherent. In manufacturing however, standardised procedures serve their purpose. The continued practice of standardised procedures and traditional command and control structures essentially describe a “management factory where the turkeys vote for Christmas”. Not good.

“Beware of work amplification processes, additional and/or excessive work-flow

“The fish rots from the head” – this was a quote that I was unaware of until today. And I’ve since found The Fish Rots from the Head by Bob Garratt in my local Waterstone’s (which, I note, links directly to Amazon now…). Anyway, the crux of the quote stemmed from the fact that unless the man at the top realises this fishy fact, the command and control architecture will never go away, inefficiencies will remain, employees continue to appear to the be low performers (in reality, it’s the work that is the low performer, not the employee – the employee doesn’t change, the work does). I thought that this was a great quote, it certainly explains a lot of things, putting a good analogy on to a common problem.

On the subject of outsourcing, John and I share a similar view: outsourcing means work will come back to you in some shape or form, it’s a boomerang. Of course, fans of outsourcing will tell you it works, but they fail to take into account the true end-to-end cost, they fail to consider the additional transactions and the boomerang activities that introduce costs into the system. John places considerable importance on understanding the cost of service, end-to-end. You wouldn’t want to outsource, especially if you can do it cheaper yourself.

Never codify method – traditionalists believe that solutions stem from “more tools more training”. Wrong, wrong, wrong: we should work on the problem instead of identifying or creating a tool. Improve the derived value by deriving or determining the real cause of waste (hint: meetings and reports won’t help you here).

“Economies of flow are much better than economies of scale. ” UK government office are attempting to promote economies of scale, all they are doing is driving waste into the system.

John discussed the Womack and Jones books and left us with a strong read recommendation for The Machine That Changed the World by James P. Womack

Determining predictable demand is key. Optimise. 60-70% of demand is the same thing – train against this demand, reduce the end-to-end cost. Understand Demand. Study demand, it “opens the whole system up”.

Lastly, John left us with a “selling” tip:

“Don’t try to sell Systems Thinking – rely on folks getting curious about it and wanting to learn more (by doing)”

[Thanks again to Clarke for the invite, and to his colleague Fiona for letting me tag along as Vision‘s guest!]

Freedom From Command and Control: The Toyota System for Service Organisations, EICC, 11th October 2005

The event was an outstanding success and by popular demand a DVD of the show will be available shortly.

Developer.* interview – now available

My interview for developer.*‘s Global Development Interview Series has now been published.

Donna Davis was the interviewer.

Dan Read (more about Dan here) has a great blog posting about the new things happening at developer.* – read it over here.

I’m excited to see that Dan’s launching developer.* books – the first book will be Software Conflict 2.0
The Art and Science of Software Engineering by Robert L. Glass (Foreword By Andrew Hunt, Pragmatic Programmers LLC) – more about this can be found here. I’d be pleased to read’n’review it Dan!

Anyway, read the full interview here.