Archive for the 'Flex' Category

Flash Video Files (.flv) and IIS

I spent the afternoon scratching my head after moving some Flash video files from my dev machine up to the web. Being essentially multi-threaded I did do some other stuff as well so it probably wasn’t as big of a problem as I am making out. Anyway…

I uploaded the files and then the viewer application thing couldn’t access them. Within the application I was switching the source of the player by replacing its HTML in the DOM using JavaScript and thus changing the videos, at least it was supposed to. (My recent discovery of the Scriptaculous/Prototype libraries made this a joy by the way.) Because of this being a bit fancy I spent quite a while blaming that and meddling with it to no avail.

I eventually had an epiphany and checked the MIME types on the server. The gist of these is that IIS only serves files that it has a MIME type for which it matches to the file extension.

By default, .flv isn’t there and thus IIS doesn’t serve the file.

To remedy this:

  • Go to the site in question in the IIS snap-in
  • Right click and open the properties for the site
  • Go to the HTTP Headers tab
  • At the bottom of said tab is a ‘MIME Types’ button which you’ll be wanting to click at this stage
  • Add a new type with the file extension .flv and the MIME type of video/x-flv.
  • Press however many ‘Yes’, ‘Apply’, ‘Finish’ or ‘OK’ buttons you need to get rid of it all…

And voila… You should be in business.

Array Serialization in Flex

I have been doing a lot of Flex work over the last couple of weeks. I have to say, it is like a dream come true after having written my fair share of code in the Macromedia Flash IDE which is something akin to eating beans with a toothpick, you get there in the end but it is a long and arduous journey. FlexBuilder, built on Eclipse, is a fully featured IDE that relieves a lot of the frustration.

Anyway, back to the plot… Being a .NET developer at heart my first foray into Flex has been a front end that sits on top of some .NET web services. There are a few options as to what you put behind your Flex apps but .NET was the best fit for the job and my skills…

So off I went and all was going swimmingly until I tried to send an array of integers from the flex app to my .NET web service. The darn thing wouldn’t work. So I opened up (the excellent, probably worth another post) Service Capture and had a look at what was being submitted to the web service.

Flex, it appears, was serializing my int array like so:


My web service was expecting:


So what did I do? I spent a while looking around the FlexCoders Yahoo group. Could’t find exactly what I was after so I posted the problem…

The upshot is there seems to be a couple of serialization bugs that Adobe are planning to sort out in the imminent service update. Whether they are responsible for my problem I didn’t find out but here’s hoping.

In the meantime my options are to send literal XML to my web service rather than allow Flex to serialize it for me. This, I imagine will require some adjustments to the back end too although  I haven’t tried it yet and don’t really want to if I can help it, simply because I shouldn’t have to in this day and age.

There are various solutions I could implement on the server such as some sort of custom deserialization but this is all very complicated just so as I can pass an array of integers and  besides which, if this is due to a bug I’ll have to undo it all when it is fixed.

Another alternative suggested on the group was to use JSON. It turns out that there is a Flex JSON implementation and a .NET one, neither of which I had heard of before. Sam Shrefler explains… Thanks Sam that looks just the ticket.

What a TODO

One of my most used features in Visual Studio over the last couple of versions has been the //TODO comment (apart from things like the code editor, the debugger etc before some smart arse points that out). Due to my over-enthusiastic social life as a youth I am not blessed with a great deal of memory, I mean in my brain as opposed to my computers where I have plenty. Consequently I find it difficult to keep track of everything I plan to do while I am writing code. I suppose, amnesiac or not, we all do when the classes start mounting up and the solutions swell.

So, for me the //TODO comment is a life saver, at least, it could be a life saver if the darned thing worked properly. I am sure it works as intended but I fail to see why the TODO Team or whoever was responsible for it limited the task list to only show TODO comments from currently open files. Not to say that this isn’t useful but, as the files are open, I could probably find those myself in a couple more seconds than it takes me to look at the task list. Valuable workflow time I agree but not as valuable as the time I lose on all of the TODOs that lurk unnoticed in all the unopen files.

Being a bit of a Flash and more recently Flex noodler I was pleased to find the TODO plug-in for FlexBuilder/Eclipse. Downloaded… Installed… works like a treat. As you add a TODO it turns up in your task list and there it stays until the TODO is TODONE. Why can’t we have this in Visual Studio?

To that end I rustled up a quick console app that you stick in the root folder of your project/solution and run. Tell it whether you are looking for .as (I did this before I started with Flex and its plug-in) or .cs files and it recurses through your folders and files and gives you a list of all your TODOs and where they are. It also counts the lines of code, excluding comments and lines that only have a curly brace on while it is at it. Am I particularly proud of myself? Well no, it is a stupid application with about ten lines of code in it but I was desperate to actually have something codesque on my blog and it was the only thing I could think of. It has also been really handy for keeping track of my TODOs so perhaps I’m being a bit harsh on myself there. I haven’t posted the source because there isn’t anything exciting in it, apart from a keylogger and a couple of trojans, but if any of my regular readers, sorry, if either of my regular readers would like it then let me know…

On that note, how the hell do you attract traffic to your blog? I have tried a couple of things with varying degress of success but am yet to pass 40 readers… Maybe that is another post.

Flex on Rails

Having endured the various failings of the Flash development experience for the last three or four versions, all the while hoping that the next version would bring such luxuries as a debugger that works or intellisense that works, I have been pleasantly suprised by Flex.

Now if you are wanting to recreate Star Wars or the Zidane headbutt incident then Flex isn’t for you as Flex is a kind of ‘Form’ based Flash rather than a timeline/movieclip job. If, however, you are after a rich UI for your application and you want it to run cross-platform in the browser then Flex is your man.

I’m sure I will write more about it in the future when I have more than the two weeks experience that I have currently but on the whole it is definitely worth a look.

Whilst looking around for resources on the web I stumbled upon a few tutorials about using Flex with Rails. Is there no escape…

(here is another one Flexstore on Rails)

RSS My Last.Fm

  • An error has occurred; the feed is probably down. Try again later.