Tag Archives: flash

“Mozilla’s new technologies” (for Mozilla Power’13)

I was going to “manifest” myself in Cairo via the powers of videoconferencing for Mozilla Power’13, but connectivity issues happened, so I recorded a screencast with my talk:

Slides

Here’s hoping the Mozilla Egypt community is having a great event :-)

Do send me any questions you might have about the topics I discussed, and I’ll do my best to answer them!

So… what do we do now with the old Flash content?

News about the imminent Flash demise are popping out everywhere you look at. The recent cancellation of Flash mobile is just a warning of what is to come. And the question that immediately came to my mind was: what with all the legacy content?

There’s a huge amount of stuff which has been programmed for Flash, for which we probably don’t have the .FLA sources anymore. What do we do with that in several years, when there isn’t an easy way to get an official Flash player which properly interacts with compiled .swf files?

For years projects like Gnash have been tried to build a free player that allowed people to run SWF files without having to go the Adobe route. But reverse engineering .swf is certainly a huge task, and sadly Gnash doesn’t support the latest SWF format versions.

At the same time, what do we do with .FLA files when we no longer can execute the Flash IDE? How do we export the assets, the code, the tweenings, and everything else?

Should we just wave goodbye to everything? Install virtual machines with old versions of operating systems? Isn’t all this a bit sad?

In any case this is an excellent example of why proprietary formats are bad, and is also a compelling reason to avoid them in the future.

I’m glad I just have a few .FLA based projects that I’d like to recover at some point, and they are relatively old anyway, so maybe with some sort of FLA to JS tool they can be easily reconstructed/exported, as they don’t use much fancy stuff.

Or so I think hope.

ruby in the pub #4 :after

Julian Burgess (who I had virtually met via Twitter) suggested me I should attend the next ruby in the pub. It sounded decidedly odd: mixing journalists with an interest for code with ruby developers; even more strange considering I’m not a ruby expert as much as I try, so I thought it could be interesting to go and see what an event like that could turn out to be.

So there I went after mentally memorising the map from Liverpool Street Station to LBi‘s offices in Brick Lane. Funny because I have done the Brick Lane-Liverpool St. route several times already, but since it was dark and I got an excellent guide, I never paid much attention. Anyway, I arrived, gave my name to the security guy which was kind of confused with my Spanish name and then went downstairs where the people with laptops on the couches were.

I took a look and didn’t know anyone — so I decided the direct approach would be better: waved and said “hi” to whoever was looking at me at that point, and got a friendly response. Yay!

In a minute I was happily talking with Francesca, a nice front end web developer, then with someone else whose name I didn’t find out, then I got to associate Julian’s name with his face. A little while after, Paul Carvill came downstairs with lots of pizza boxes –all vegetarian, and yummy!– and as we were discussing about Rails 3.0, Joanna Geary made a little speech, more or less on the lines of this:

‘Journalists, raise your hands!’

They do.

‘Journalists, find a developer and explain them what do you have in mind that could be done with code, and let’s see if it’s doable or not!’

And then a girl approached Francesca and me. She looked strangely familiar but I couldn’t really tell why. We sat in a table, took the laptops out of their sleeves and set out to try and find if the data we needed was available. But the wireless didn’t quite work. So we chatted about something fascinating and kind of related to the topic: Volcanoes! It really helped that she had a degree in Geology so she could really offer interesting insight about how volcanoes work. Also, amazing as it sounds, she could pronounce Eyjafjallajökull in one go without hesitation!

We ate some more pizza, and then the wireless started working. So we checked and saw that the data wasn’t available — but we agreed she would contact the organisation and ask them for it. Maybe they already have it but it’s not publicly advertised.

Then it’s when the real coding part began; she said she would love to learn programming, but didn’t know where to start, or the guides she had tried were boring. I immediately proposed Processing; I know there’s Hackety Hack by _why, which is ruby based, but I don’t have any experience with it, so I went for the safer option.

I actually hadn’t done much Processing recently and as such I always forget the names of the basic functions (was it setup, or was it load? was it loop or was it play?) but it was even better, so that way they could follow along. She downloaded Processing and was typing in stuff in the sketchbook immediately… which was amazing! No setup, no preparation, no rebooting the computer after the installation; just download and experiment!

We’ve done just extremely simple things such as opening a window, setting its background colour, changing its size and… drawing a line! Still, I find it really enlightening to observe how ‘normal people’ (i.e. not hardcore developers) react to all these concepts when exposed to them.

Interesting things I’ve noticed (teachers, take note!):

  • people love to see results immediately – no theory to start with!
  • people love to have some starting snippets, which they can modify and experiment with, learning how they work meanwhile

So that makes Processing an excellent programming environment for beginners, because it’s got that beatiful reference written in pretty much plain language and with example snippets that can be copied and pasted for each function/class.

In a few minutes the word had spread: there were people doing stuff with Processing in the room! And so a little audience gathered, another guy (a journalist) came with his laptop, downloaded Processing and was doing little simple things as the aforementioned ones, copying code from her wife’s screen –isn’t it sweet?

On the other side of the table I was showing Paul and Francesca my word processing and statistical experiments with Tolkien works and we also spoke about Processing versus other environments such as Javascript or Flash.

In between, the girl had told us her name, and if the face looked familiar, the name was insanely familiar! She humbly told me she was in lots of events and etc, but didn’t make a big thing of it. I asked her about events I had been in (that I could recall at that point) to no avail –we didn’t seem to have been in the same events. But then I came home and looked for “Suw Charman” and found that not only had I seen her speak at resfest’05 but she had also posted a few messages to a mailing list I follow. I think that’s why the name sounded sooo familiar!

Of course, there couldn’t be a nice event without Rob McKinnon in it! I just love how I always find him everywhere I go, whether it’s a full fledged event or just a coffee shop anywhere in London, it’s just so funny. Couldn’t exchange more than a few “hey hey hi!” waves because we both were busy with our new friends, so I don’t know which sorts of interesting stuff did he show this time (the last time he spoke about Hpricot).

The event ended at around 22h, but mainly because people had to leave and take trains and all those things, but I’m pretty sure otherwise we could have stayed and playing with Processing for a long while :-)

And that’s how ruby in the pub, “with hardly any ruby and certainly no pub”, was. See you in the next one?

Should PDFs be next?

Everyone has experienced this: you’re happily browsing a site, click on a link to get more information about something and then… TADA! You’re downloading a PDF! Or, depending on your browser’s settings, you could either have the PDF open in the very same window/tab, or get a new window/tab open with the PDF in them, or even more funnily, you get a new window/tab and the browser prompting you to select a download location for the PDF.

It’s an awful mess.

Some websites add a “[PDF]” text close to the link, to point out it’s not a normal link. Fair enough. But most of the data they include in a PDF should and can be web accessible. It’s just tables of data and facts, after all!

Why do these websites tease users first and then punish them with a PDF when they want to get to the data?

Transport companies are exceptionally guilty of this. I wonder if it’s due to laziness, incompetence or simply a consequence of their internal approval processes not being able to verify and give the seal of approval to anything else once they’re done with the PDFs.

Some examples

Transport For London

TFL
(link)

They used to offer a .GIF version of the tube map. It’s not there any more; now you have to resign yourself with a PDF, or a ridiculously small Flash widget-ish “Interactive map” that won’t fill even 25% of the width of my screen and is as interactive as a push button.

Southern trains

There’s no way of getting an HTML timetable. You must download a PDF, or maybe if you register and create one of those custom timetables you get an HTML. But honestly, that’s even more of a hassle than the PDF only.

Southern
(link)

Green line

Again, PDF is the only option if you want to consult the timetables.

Green line
(link)

And the list goes on and on and on…

PDFs are a barrier

Instead of being useful and informative, they’re just forcing me to go through a format and layout that haven’t been designed for web: these documents are meant to be printed. And their pages flipped physically, and sometimes you’re expected to hold the index page with one hand while browsing through the required page(s) with the other hand.

Sometimes you even have to rotate the PDF in order to properly read it. Easy to do if you’re holding a physical leaflet in your hands, not so with some PDF readers… and less tech-savvy people don’t even know they can rotate the PDFs: they turn their heads in a very uncomfortable way instead.

Also, did they think of people using alternative devices such as a phone or a console for accessing the website? Yes, there are PDF readers for some of those phones, but for a console? And why should we abandon the context we are in (the browser, or the couch, in the case of the console) and climb the PDF barrier in order to finally access the data we are so desperately looking for?

Oh, and did I mention how huge and heavy PDFs are in comparison with a simple web page because they are meant to be printed and all the fonts and shapes are embedded? It’s even more outrageous when you just need to access a single page from the full document.

It doesn’t matter that much when you’re using a computer and a proper DSL connection, but it definitely matters when you’re on the go and using an unreliable, slow 3G connection.

The irony

PDF stands for Portable Document Format.

But is there anything more portable than HTML? (apart from plain text). It’s lightweight to process, can be accessed even in low-profile phones like my old trustful v630i, and you don’t need to install any plug-in to read its contents.

v630i

Yes

PDFs should be next.

Their gratuitous use should be condemned and exterminated, just as the irresponsible use of Flash is thankfully diminishing (although mainly because His Jobness decided he didn’t like Flash and all that).

We should be able to access all the contents a website has to offer, by simply using a browser. That simple.

Of course, this requires a mentality change, where the content in the website is adapted to the web format and conventions, instead of simply placing a series of files for download in the website and calling it a day.

Maybe that’s what Web 3.0 will really bring…

Embedding fonts in ActionScript 3, using Flex SDK

Say you have a class and you want to use an embedded, non-system font in the class. That way you can rotate, scale, change alpha and apply filters to the text. And this is how it would look like, roughly:

public class MyClass extends Sprite
{
        [Embed(source="./../assets/MyFontLightItalic.TTF", fontFamily="MyFontFamily", fontWeight= "light", fontStyle = "italic", mimeType="application/x-font-truetype")]
        private var MyFont:Class;

        public function MyClass()
        {
                var tf:TextField = new TextField();
                tf.embedFonts = true;
                tf.defaultTextFormat = new TextFormat("MyFontFamily", 17, 0x7F7F7F);
        }
}

You might also need to make sure you’re linking to framework.swc, or otherwise you will get some strange errors like Error: The definition of base class FontAsset was not found.

Interesting stuff

Because most of the examples out there simply use “Arial” as font, they will never get the myriad errors I was getting, such as “Error: exception during transcoding: Font for alias ‘Blah Blah Light Italic’ with plain weight and style was not found” or the much dreaded “Error: java.lang.Integer cannot be cast to java.lang.String”.

The problem is that there are more sophisticated True Type Fonts out there, which split the font in several files, one for each variation of weight and style, and if you try to embed a file for a non normal weight, normal style, the Flex compiler won’t be able to find the definition of the shapes for the “normal version” and then will simply stop and let you wondering why it doesn’t work.

So that’s why we’re specifying not only the source file but also the weight and style of the font, and that’s what most of the examples never deal with — because Arial comes as a single file.

Then there’s the other important thing: the private class to which the font file will be attached. Even if you simply use the embedded font with the new alias defined in fontFamily (“MyFontFamily” in this example), you still need to provide that variable, or you will get a big “Error #2136: the swf file contains invalid data”.

More info

I assembled the solution to my woes taking parts from several sources: