Talk to my... Flash?

According to normal acceptable behaviour it is not possible to let flash talk to the computer, be it on desktop or web browser.

There are always ways around a problem and there’s one in this case as well.

Windows Forms

If you wanted to access .net functions on windows form then probably a good way to do that would be through ShockWaveFlashObjects library. It wraps all the functions that are available in ShockWave Objects and makes them available to you in .Net type safe way.

The easiest of ways to send data back and forth would be through fscommand function. The concept is to embed a flash file in windows form and then make use of fscommand function.

Tip: Remember to remove the blue window bondary at the top so the flash appears as if its a standalone object and not embedded inside another form!


If you wanted to talk over a web page then an easy way out would be to use AMF.Net software. It is a freeware and very easy to use as well. In the words of its official website:

“AMF enables developers to build powerful flash-based applications driven by databases and rich business layers. AMF.NET is a .NET gateway sitting between a Flash movie and .NET code. The goal of AMF.NET is to promote proper N-Tier development by allowing your existing business layer (written in .NET) to be consumed by Flash without requiring any modification.”

Membership and Profiler in ASP.NET

Whenever you are using Sql Membership and Profiler classes - Trying to generate reports make sure your query’s WHERE clause is using “indexed” column names at least.

Let’s look at some of the more used tables. The index of some of the tables is given below:

Table: aspnet_membership

  • Clustered Index = ApplicationID, LoweredEmail

  • NonClustered = UserID

Table: aspnet_users

  • Clustered Index = ApplicationID, LoweredUserName

  • NonClustered Index = ApplicationID, LastActivityDate

  • Primary Key = UserID

Table: aspnet_Profile

  • Clustered Index = UserID
Bottomline - try to use ApplicationID in your queries otherwise your queries, for sure, will not run over the index at all and make it slow. This comes in effect if you are expecting high volume.

Book Review: Head First Design Patterns

What an amazing book this is! It is a must read for any developer who wants to develop long term codes/projects.

The book looks at mostly the more important design patterns. The distinctive feature that stands out in this book is how it manages to make each pattern stand out against each other. It gives comparison between similar-looking patterns where necessary. It make the patterns “debate” against each other, get the birds-eye-view from “patterns guru and grasshopper discussion”, UML like “class diagrams with notes” to show how everything is gelling together.

It starts off every pattern with the basic situation and come up with a code how a normal developer would code - then give that situation a twist and show us mortal beings how to code again using a pattern! It is a perfect setup for even a novice to get it straight into his head.

The code for this book can be picked up at

Although this book is written for Java developers but it should suit C# and VB.NET. The website includes code for C# as well donated by a reader of the book.

Dynamically increase Label size [AutoSize]

Recently I had to work on a windows form where the Labels are added dynamically onto the form. Some of you may think that setting AutoSize to true would fix the problem but it works only when you already have added that Label control onto the form, not when you are adding it dynamically.

Despair not, there’s still a solution. Just create a label and set it’s text first then call this function:

If you do some testing it may not work on Compact Framework. Here’s how to get around that issue again.

Use of yield statement

It might be a little late for this to appear but I have no qualms in accepting that I have finally embraced yield statement and see it as an excellent way of writing codes.

I have had my fair share of writing small code fragments to read/process/write files and more often than that it is excel files. So I thought, there has to be an easier way than just creating common functions for Connections and processing functions - at that time yield statement came to the rescue. I have always had to read the excel file, one line after another - pretty much like a DataTable if you ask me.

The best way to put the whole process of reading the excel file is to automate reading, iterating and closing of the excel files. It is done by yield statement as I can “yield” the data of the excel through DataReader (OdbcDataReader in my case).

This way, the function is always common - it is always supposed to read the excel, iterate through it. The data that I need is always in the DataReader so I thought let’s just return the data itself! The rest of the function is pretty much normal. The biggest gain is that I don’t have to change the structure of the function. The same function can now be used for multiple excel sheets. Have a look at the code.